Skip to content

Commit

Permalink
Fix schedule:list to handle fluent-style scheduling constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
Gajarthan committed Jun 27, 2024
1 parent 7e43459 commit 9745593
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Illuminate/Console/Scheduling/ScheduleListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,33 @@ public function handle(Schedule $schedule)
$this->line(
$events->flatten()->filter()->prepend('')->push('')->toArray()
);

$this->table(
['Expression', 'Command', 'Next Due'],
$this->getScheduleList()
);
}

protected function getScheduleList()
{
$events = $this->laravel->make(Schedule::class)->events();
$list = [];

foreach ($events as $event) {
$expression = $event->expression;
$command = $event->command ?? $event->description;
$nextDue = $event->nextRunDate()->diffForHumans();

// Handle the 'between' constraint manually
if ($event->filters && isset($event->filters['between'])) {
$between = $event->filters['between'];
$expression .= " between " . implode(' and ', $between);
}

$list[] = [$expression, $command, $nextDue];
}

return $list;
}

/**
Expand Down

0 comments on commit 9745593

Please sign in to comment.