where('is_paused', false) ->where('is_deleted', false) ->whereNotNull('next_run') ->where('next_run', '<=', now()) ->cursor() ->each(function ($scheduler) { $this->doJob($scheduler); }); } } private function doJob(Scheduler $scheduler) { nlog("Doing job {$scheduler->name}"); try { $scheduler->service()->runTask(); } catch(\Exception $e){ nlog($e->getMessage()); } } }