%PDF- %PDF-
Direktori : /var/www/html/hr/api/app/Console/Commands/ |
Current File : /var/www/html/hr/api/app/Console/Commands/CheckForUsersBirthdayCommand.php |
<?php namespace App\Console\Commands; use App\Models\User; use Carbon\Carbon; use Illuminate\Console\Command; class CheckForUsersBirthdayCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'checkForUsersBirthdayCommand'; /** * The console command description. * * @var string */ protected $description = 'Daily check for birthdays and sending them a notification'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. */ public function handle() { $users = User::query() ->whereRaw('DATE_FORMAT(birthday, "%m-%d") = ?', [ Carbon::now() ->format('m-d'), ]) ->get(); /** @var User $user */ foreach ($users as $user) { $user->sendBirthdayNotification(); } } }