Php 是否可以将数据从控制器传递到内核调度?
我正在进行任务调度,以便在特定日期或时间向用户发送sms通知。是否可以将数据从控制器传递到内核调度?比如说:Php 是否可以将数据从控制器传递到内核调度?,php,laravel,Php,Laravel,我正在进行任务调度,以便在特定日期或时间向用户发送sms通知。是否可以将数据从控制器传递到内核调度?比如说: protected function schedule(Schedule $schedule) { $schedule->command('sms:send')->dailyAt($time); } 如果可能的话,有什么建议吗?非常感谢。您可以将控制器调用到Console/Commands/Yourclass 类似于handle()函数中的- protected $
protected function schedule(Schedule $schedule)
{
$schedule->command('sms:send')->dailyAt($time);
}
如果可能的话,有什么建议吗?非常感谢。您可以将控制器调用到Console/Commands/Yourclass 类似于handle()函数中的-
protected $signature = 'showing:rating'; //your command
//you can write and call logic here in handle function
public function handle()
{
$rating = (new CronController())->showingRating();
}
然后你就可以调用你的命令了Kernel@schedule()功能是这样的-
protected function schedule(Schedule $schedule)
{
$schedule->command('showing:rating')
->hourly();
}
希望这将对您有所帮助。您可以调用controller到Console/Commands/Yourclass 类似于handle()函数中的-
protected $signature = 'showing:rating'; //your command
//you can write and call logic here in handle function
public function handle()
{
$rating = (new CronController())->showingRating();
}
然后你就可以调用你的命令了Kernel@schedule()功能是这样的-
protected function schedule(Schedule $schedule)
{
$schedule->command('showing:rating')
->hourly();
}
希望这会对您有所帮助。我认为您必须创建自己的命令,并且使用handel方法可以获取所需数据==>很抱歉响应太晚。谢谢你,Maraboc。我认为你必须创建自己的命令,在handel方法中,你可以得到你想要的数据==>很抱歉反应太晚。谢谢你,Maraboc,很抱歉反应太晚。我不太明白
$rating=(新的CronController())->showingRating()代码>特别是showingRating()。无论如何,谢谢您的时间。CronController是我的控制器,showingRating()是在CronController中定义的函数。这里,我调用CronController中的showingRating()函数$评级=(新CronController())->showingRating();我懂了。我现在明白了。非常感谢。很抱歉反应太晚。我不太明白$rating=(新的CronController())->showingRating()代码>特别是showingRating()。无论如何,谢谢您的时间。CronController是我的控制器,showingRating()是在CronController中定义的函数。这里,我调用CronController中的showingRating()函数$评级=(新CronController())->showingRating();我懂了。我现在明白了。非常感谢你。