app->runningInConsole()) { return; } // Guard against table not existing (pre-migration) if (! Schema::hasTable('scheduled_actions')) { return; } $this->app->booted(function () { $schedule = $this->app->make(Schedule::class); $actions = ScheduledAction::enabled()->get(); foreach ($actions as $action) { $class = $action->action_class; if (! class_exists($class)) { continue; } $event = $schedule->call(function () use ($class, $action) { $class::run(); $action->markRun(); })->name($class); // Apply frequency $method = $action->frequencyMethod(); $args = $action->frequencyArgs(); $event->{$method}(...$args); // Apply options if ($action->without_overlapping) { $event->withoutOverlapping(); } if ($action->timezone) { $event->timezone($action->timezone); } } }); } }