Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Allow appending of rows to Artisan tables #31426

Merged
merged 1 commit into from
Feb 11, 2020
Merged

[6.x] Allow appending of rows to Artisan tables #31426

merged 1 commit into from
Feb 11, 2020

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
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