Skip to content

Commit b06be42

Browse files
cwt137taylorotwell
authored andcommitted
[5.5] Allow setting column styles for tables in Artisan commands (#21169)
* Allow setting column styles for tables in Artisan commands * Fix indentation * Fix indentation
1 parent 46a65c9 commit b06be42

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Illuminate/Console/Command.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -378,18 +378,25 @@ public function choice($question, array $choices, $default = null, $attempts = n
378378
*
379379
* @param array $headers
380380
* @param \Illuminate\Contracts\Support\Arrayable|array $rows
381-
* @param string $style
381+
* @param string $tableStyle
382+
* @param array $columnStyles
382383
* @return void
383384
*/
384-
public function table($headers, $rows, $style = 'default')
385+
public function table($headers, $rows, $tableStyle = 'default', array $columnStyles = [])
385386
{
386387
$table = new Table($this->output);
387388

388389
if ($rows instanceof Arrayable) {
389390
$rows = $rows->toArray();
390391
}
391392

392-
$table->setHeaders((array) $headers)->setRows($rows)->setStyle($style)->render();
393+
$table->setHeaders((array) $headers)->setRows($rows)->setStyle($tableStyle);
394+
395+
foreach ($columnStyles as $columnIndex => $columnStyle) {
396+
$table->setColumnStyle($columnIndex, $columnStyle);
397+
}
398+
399+
$table->render();
393400
}
394401

395402
/**

0 commit comments

Comments
 (0)