phpvms/app/Cron/Nightly/PilotLeave.php
Arthur Parienté 992b6d343a
[8.x] feature: upgrade to Laravel 13 (#2204)
* upgrade to laravel 13

* phpstan

* rollback to symfony 7.4

* fix: ModuleService merge

* refactor: new rector rules
2026-05-06 11:27:21 -05:00

41 lines
1017 B
PHP

<?php
namespace App\Cron\Nightly;
use App\Contracts\Listener;
use App\Events\CronNightly;
use App\Services\UserService;
use Illuminate\Support\Facades\Log;
use InvalidArgumentException;
use UnexpectedValueException;
/**
* Determine if any pilots should be set to ON LEAVE status
*/
class PilotLeave extends Listener
{
/**
* PilotLeave constructor.
*/
public function __construct(private readonly UserService $userSvc) {}
/**
* Set any users to being on leave after X days
*
*
* @throws UnexpectedValueException
* @throws InvalidArgumentException
*/
public function handle(CronNightly $event): void
{
Log::info('Cron: Running pilot leave check');
$users = $this->userSvc->findUsersOnLeave();
Log::info('Found '.count($users).' users on leave');
foreach ($users as $user) {
Log::info('Setting user '.$user->ident.' to ON LEAVE status');
$this->userSvc->setStatusOnLeave($user);
}
}
}