I am new to laravel. I just made a command which adds 10 points for each user. It is running successfully when executed but when I use it with the task scheduler it doesn't work. Here is my command :
public function handle()
{
$x = User::all();
foreach ($x as $c){
$u['points'] = $c->points + 10;
User::where('id' , $c->id)->update($u);
}
echo 'Daily Bonus Given';
}
Here is my Kernel file :
protected $commands = [
Commands\daily_bonus::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('daily:bonus')
->everyMinute();
}
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
require base_path('routes/console.php');
}
When I run php artisan schedule:run
, it executes the command only the first time and not after a regular interval. Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire