command('inspire')->hourly(); $schedule->command('Bonus:MonthPerf 1')->monthlyOn(1, '00:01'); $schedule->command('Bonus:StartMonth 1 1')->monthlyOn(1, '00:10'); $schedule->command('Bonus:StartMonth 2 1')->monthlyOn(1, '00:15'); $schedule->command('Bonus:StartMonth 3 1')->monthlyOn(1, '00:20'); $schedule->command('Bonus:StartMonth 4 1')->monthlyOn(1, '00:25'); $schedule->command('Bonus:StartMonth 5 1')->monthlyOn(1, '00:30'); $this->modules($schedule); } /** * 要执行任务的位置增加Console\Kernel类 * 类中 runCommand(Schedule $schedule) * 模型中的command在模型的ServiceProvider自行注册 * @param \Illuminate\Console\Scheduling\Schedule $schedule */ protected function modules(Schedule $schedule) { $data = ModuleManager::toCollection(); foreach ($data as $name => $module) { $nameSpace = "\\Modules\\$name\\Console\\Kernel"; if (class_exists($nameSpace)) { $runKernel = resolve($nameSpace); $runKernel->runCommand($schedule); } } } /** * Register the commands for the application. * @return void */ protected function commands() { $this->load(__DIR__.'/Commands'); // require base_path('routes/console.php'); } }