-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
display a table of all the scheduled commands
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Illuminate\Console\Scheduling; | ||
|
||
use Cron\CronExpression; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Carbon; | ||
|
||
class ScheduleListCommand extends Command | ||
{ | ||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'schedule:list'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'List the scheduled commands'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @param \Illuminate\Console\Scheduling\Schedule $schedule | ||
* @return void | ||
* @throws \Exception | ||
*/ | ||
public function handle(Schedule $schedule) | ||
{ | ||
foreach ($schedule->events() as $event) { | ||
$rows[] = [ | ||
$event->command, | ||
$event->expression, | ||
$event->description, | ||
(new CronExpression($event->expression))->getPreviousRunDate(Carbon::now()), | ||
(new CronExpression($event->expression))->getNextRunDate(Carbon::now()), | ||
]; | ||
} | ||
|
||
$this->table([ | ||
'Command', | ||
'Interval', | ||
'Description', | ||
'Last Run', | ||
'Next Due', | ||
], $rows ?? []); | ||
} | ||
} |