我正在進行任務調度,以便在特定日期或時間向用戶發送短信通知。是否有可能將數據從控制器傳遞到內核計劃?比方說:是否可以將數據從控制器傳遞到內核計劃?
protected function schedule(Schedule $schedule)
{
$schedule->command('sms:send')->dailyAt($time);
}
如果可能的話,有關如何做的提示?非常感謝你。
我正在進行任務調度,以便在特定日期或時間向用戶發送短信通知。是否有可能將數據從控制器傳遞到內核計劃?比方說:是否可以將數據從控制器傳遞到內核計劃?
protected function schedule(Schedule $schedule)
{
$schedule->command('sms:send')->dailyAt($time);
}
如果可能的話,有關如何做的提示?非常感謝你。
你可以叫控制器控制檯/命令/ Yourclass
像這樣的手柄()函數 -
protected $signature = 'showing:rating'; //your command
//you can write and call logic here in handle function
public function handle()
{
$rating = (new CronController())->showingRating();
}
然後你就可以在內核@時間表打電話給你的命令()函數這樣的 -
protected function schedule(Schedule $schedule)
{
$schedule->command('showing:rating')
->hourly();
}
希望這會對你有幫助。
對不起,遲到的迴應。我不太明白'$ rating =(new CronController()) - > shownRating();'特別是showsRating()。無論如何,謝謝你的時間。 –
CronController是我的控制器,而showsRating()是一個在CronController中定義的函數。在這裏,我調用了CronController中的showsRating()函數。 $ rating =(new CronController()) - > shownRating(); –
我明白了。我現在明白了。非常感謝你。 –
我認爲你必須創建你自己的命令,並且在handel方法中你可以得到你想要的數據==> [閱讀更多](https://laravel.com/docs/5.5/artisan#writing-commands) – Maraboc
對不起對於遲到的迴應。謝謝Maraboc。 –