jeudi 26 juillet 2018

Laravel 5.5: Want to run multiple cronjobs through kernel.php under App/Console

I want to run different cronjobs like deleting users, send coupon codes to users, send greeting to users who joined between specified dates and etc. Can I do the same by opening the App\Console\Kernel.php and write the command as below:

protected $commands = [
         '\App\Console\Commands\DeleteUsers',
         '\App\Console\Commands\SendCouponCode',
         '\App\Console\Commands\SendGreetings',
];

protected function schedule(Schedule $schedule)
{        
 $schedule->command('DeleteUsers:deleteuserscronjob')->everyMinute();
 $schedule->command('SendCouponCode:sendcouponcodecronjob')->everyMinute();
 $schedule->command('SendGreetings:sendgreetingscronjob')->everyMinute();
}

Also, can someone suggest how to run cronjobs by calling only the methods under controllers and not by commands, as like below?

App\Http\Controllers\MyController1@MyAction1

And,

App\Http\Controllers\MyController2@MyAction2



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire