diff --git a/src/Liebig/Cron/ListCommand.php b/src/Liebig/Cron/ListCommand.php index 1d89e96..8f7aed8 100644 --- a/src/Liebig/Cron/ListCommand.php +++ b/src/Liebig/Cron/ListCommand.php @@ -41,23 +41,49 @@ public function fire() { // Get all registered Cron jobs $jobs = Cron::getCronJobs(); - // Create the table helper with headers. - $table = $this->getHelperSet()->get('table'); - $table->setHeaders(array('Jobname', 'Expression', 'Activated')); - - // Run through all registered jobs - for ($i = 0; $i < count($jobs); $i++) { - - // Get current job entry - $job = $jobs[$i]; - - // If job is enabled or disable use the defined string instead of 1 or 0 - $enabled = $job['enabled'] ? 'Enabled' : 'Disabled'; - - // Add this job to the table. - $table->addRow(array($job['name'], $job['expression']->getExpression(), $enabled)); + // Get Laravel version + $laravel = app(); + $version = $laravel::VERSION; + + if ($version < '5.2') { + // Create the table helper with headers. + $table = $this->getHelperSet()->get('table'); + $table->setHeaders(array('Jobname', 'Expression', 'Activated')); + + // Run through all registered jobs + for ($i = 0; $i < count($jobs); $i++) { + + // Get current job entry + $job = $jobs[$i]; + + // If job is enabled or disable use the defined string instead of 1 or 0 + $enabled = $job['enabled'] ? 'Enabled' : 'Disabled'; + + // Add this job to the table. + $table->addRow(array($job['name'], $job['expression']->getExpression(), $enabled)); + } + } else { + // Create table for new Laravel versions. + $table = new \Symfony\Component\Console\Helper\Table($this->getOutput()); + $table->setHeaders(array('Jobname', 'Expression', 'Activated')); + + $rows = []; + // Run through all registered jobs + for ($i = 0; $i < count($jobs); $i++) { + // Get current job entry + $job = $jobs[$i]; + + // If job is enabled or disable use the defined string instead of 1 or 0 + $enabled = $job['enabled'] ? 'Enabled' : 'Disabled'; + + array_push($rows, array($job['name'], $job['expression']->getExpression(), $enabled)); + + } + + $table->setRows($rows); } + // Render and output the table. $table->render($this->getOutput()); }