Initial commit

This commit is contained in:
2026-02-06 23:26:56 +07:00
commit d6022b9bca
92 changed files with 41386 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
namespace App\Console\Commands;
use App\Enums\TaskStatus;
use App\Models\Task;
use App\Notifications\TaskOverdueNotification;
use Illuminate\Console\Command;
final class NotifyOverdueTasks extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'tasks:notify-overdue';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle(): int
{
Task::query()
->whereNotNull('due_date')
->where('due_date', '<', now()->toDateString())
->where('status', '!=', TaskStatus::COMPLETED)
->whereNull('notified_at')
->with('user')
->chunkById(100, function ($tasks) {
foreach ($tasks as $task) {
$task->user->notify(
new TaskOverdueNotification($task)
);
$task->update([
'notified_at' => now(),
]);
}
});
$this->info('Tasks overdue notification send)');
return self::SUCCESS;
}
}