%PDF- %PDF-
Direktori : /var/www/html/geotechnics/api/app/Console/Commands/ |
Current File : /var/www/html/geotechnics/api/app/Console/Commands/NotifyManagerForProjectDeadlineCommand.php |
<?php namespace App\Console\Commands; use App\Models\Project; use App\Models\ProjectStatus; use App\Notifications\NotifyManagerForProjectDeadline; use Carbon\Carbon; use Illuminate\Console\Command; class NotifyManagerForProjectDeadlineCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'notifyManagerForProjectDeadlineCommand'; /** * The console command description. * * @var string */ protected $description = 'Notify managers for project with deadline in 7 days.'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return mixed */ public function handle() { $date = Carbon::now() ->addWeek() ->format('Y-m-d'); $projects = Project::query() ->whereIn('status', [ProjectStatus::TODO, ProjectStatus::DOING]) ->where('due_date', $date) ->get(); /** @var Project $project */ foreach ($projects as $project) { $project->manager->notify(new NotifyManagerForProjectDeadline($project)); } } }