Skip to content

Instantly share code, notes, and snippets.

@itsgoingd
Created September 26, 2017 11:02
Show Gist options
  • Save itsgoingd/f54ae2870e14bd1882ab1ed3644df5f3 to your computer and use it in GitHub Desktop.
Save itsgoingd/f54ae2870e14bd1882ab1ed3644df5f3 to your computer and use it in GitHub Desktop.
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
collect(cache('tasks'))->each(function ($task) use ($schedule) {
$schedule->job($task['job'])->everyFiveMinutes()->between($task['from'], $task['to']);
// you can wrap the job registration in the task class to allow specifying any schedule options
$task->schedule($schedule);
});
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment