From b0fcdaa3756f844332e2be5e2b36e270e8a4cdb6 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 15 Jun 2018 14:14:04 +1000 Subject: [PATCH] Added artisan command schedule:list --- src/Commands/ScheduleList.php | 66 +++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/Commands/ScheduleList.php diff --git a/src/Commands/ScheduleList.php b/src/Commands/ScheduleList.php new file mode 100644 index 0000000..8d98abe --- /dev/null +++ b/src/Commands/ScheduleList.php @@ -0,0 +1,66 @@ +schedule = $schedule; + } + + /** + * Execute the console command. + * + * @return mixed + */ + public function handle() + { + $events = array_map(function ($event) { + return [ + 'cron' => $event->expression, + 'command' => static::fixupCommand($event->command), + ]; + }, $this->schedule->events()); + + $this->table( + ['Cron', 'Command'], + $events + ); + } + + /** + * If it's an artisan command, strip off the PHP + * + * @param $command + * @return string + */ + protected static function fixupCommand($command) + { + $parts = explode(' ', $command); + if (count($parts) > 2 && $parts[1] === "'artisan'") { + array_shift($parts); + } + + return implode(' ', $parts); + } +}