Skip to content

Conversation

@adam-prickett
Copy link
Contributor

As a fix to the issue @freekmurze raised (laravel/ideas#2064) on using appendRow() on a Table within Artisan commands, this PR enables that feature by passing a ConsoleSectionOutput to the Table constructor, thus creating a new section.

The Table instance is also now returned following render, which allows appendRow() to be called on the rendered table.

Example:

public function handle()
{
    $table = $this->table(
        ['Column', 'Another column'],
        []
    );

    $table->appendRow(['Value', 'Another Value']);
    $table->appendRow(['Value', 'Another Value']);
}

Output:

+--------+----------------+
| Column | Another column |
+--------+----------------+
| Value  | Another Value  |
| Value  | Another Value  |
+--------+----------------+

@GrahamCampbell GrahamCampbell changed the title Allow appending of rows to Artisan tables [6.x] Allow appending of rows to Artisan tables Feb 11, 2020
@freekmurze
Copy link
Contributor

@adam-prickett Thank you for this 👍

@taylorotwell taylorotwell merged commit 3422a24 into laravel:6.x Feb 11, 2020
@adam-prickett adam-prickett deleted the enable-appendrow-for-artisan-table branch February 11, 2020 14:08
@taylorotwell
Copy link
Member

We may have to revert this. It's been a pretty big disaster and headache ever since just to appease this one small use case. Breaking the build on master branch now because of failure to implement some stream methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants