Scheduing progress

This commit is contained in:
Jonatan Rek 2024-08-06 07:17:35 +02:00
parent bb450e3a80
commit 2dfb12f23d

View File

@ -30,9 +30,17 @@ public function handle(): void
{ {
$maintenances = Maintenance::all(); $maintenances = Maintenance::all();
foreach ($maintenances as $maintenance) { foreach ($maintenances as $maintenance) {
$cron = new CronExpression($maintenance->schedule); $valid = CronExpression::isValidExpression($maintenance->schedule);
dump($cron->getNextRunDate(null, 2)->format('Y-m-d H:i:s')); if (!$valid) {
dd($maintenance->schedule);
return;
}
$cron = new CronExpression($maintenance->schedule);
if (!$cron->isDue('now')) {
dd($cron->getNextRunDate());
return;
}
$maintenance->history()->create([ $maintenance->history()->create([
'start_at' => $cron->getNextRunDate(null, 2) 'start_at' => $cron->getNextRunDate(null, 2)