当前位置: 首页 > 后端技术 > PHP

Laravel8控制台调度实例

时间:2023-03-29 16:09:35 PHP

command('es:init')->dailyAt('1:00');$schedule->command('enterprise:status')->dailyAt('2:00');$schedule->command('delete:removed')->sundays();//每周执行一次}/***为应用程序注册命令。**@returnvoid*/protectedfunctioncommands(){$this->load(__DIR__.'/Commands');需要base_path('routes/console.php');}}removeClass){foreach($this->removeClassas$value){$model=new$value;$model::where('isRemoved',1)->delete();}}返回真;}publicfunctionhandle(){$this->deleteRemoved();}}