I've written a L4 Command class but the table
output is throwing an exception.
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class Table extends Command {
protected $name = 'table';
public function fire()
{
//output table;
$header = ['Name', 'Email', 'Age'];
$row = ['Luke', '[email protected]', '99'];
$this->info(sprintf("is array ? %s", is_array($row) ? 'true' : 'false'));
//outputs is array ? true
$this->table($header, $row);
//throws exception
// [InvalidArgumentException]
// A row must be an array or a TableSeparator instance.
}
}
Any ideas?
You have to pass in an array of rows. Per table
definition:
void table(array $headers, array $rows, string $style = 'default')
So you either do
$row = [['Luke', '[email protected]', '99']]; // An array of arrays, containing one row
or
$this->table($header, [$row]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With