forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScheduleListCommand.php
52 lines (46 loc) · 1.2 KB
/
ScheduleListCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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 ?? []);
}
}