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; } }