reminder for todos
This commit is contained in:
1 parent
f78740fbb0
commit
ec6d7e2a80
9 files changed
+171
-27
No files matched your search
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\TodoMail;
|
||||
use App\Models\Todo;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
#[Signature('app:send-todo-follow-up-reminders')]
|
||||
#[Description('Send reminder emails for todos whose follow-up date has been reached')]
|
||||
class SendTodoFollowUpReminders extends Command
|
||||
{
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$todos = Todo::query()
|
||||
->whereNull('done_date')
|
||||
->whereNull('follow_up_notified_at')
|
||||
->whereNotNull('follow_up')
|
||||
->whereDate('follow_up', '<=', today())
|
||||
->get();
|
||||
|
||||
foreach ($todos as $todo) {
|
||||
foreach ($todo->getassignetusers() as $user) {
|
||||
Mail::to($user)->send(new TodoMail($todo, 'Todo Wiedervorlage', 'Die Wiedervorlage für folgende Todo ist erreicht:'));
|
||||
}
|
||||
|
||||
$todo->follow_up_notified_at = now();
|
||||
$todo->saveQuietly();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user