Laravel Scheduling call controller

后端 未结 5 1684
北荒
北荒 2021-01-04 05:23

I work with Laravel Task Scheduling, but I have a problem when I call some method from my controller.

protected function schedule(Schedule $schedule)
{
    $         


        
5条回答
  •  死守一世寂寞
    2021-01-04 05:41

    Also now I test with more simple function to insert new currency in database. Here is code:

    public function handle()
        {
            $currency                = new Currency();
            $currency->currency_name = 'EUR';
            $currency->save();
    
            $this->info('New currency is successfully generated!');
        }
    

    This function is from laravel/app/Console/Commands. I call from Kernel > schedule(). Not work.

    When I insert simple log write to handle() function like:

    File::put(base_path() . '/storage/logs/test_logs.txt', 'Test log ' . Carbon::now()->format('Y-m-d H:i:s') . PHP_EOL);
    

    this works. But when I try to create new object from Models and save into db -> this not work.

提交回复
热议问题