Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Table using Schema-like Syntax #1

Open
crynobone opened this issue Jun 6, 2012 · 2 comments
Open

Table using Schema-like Syntax #1

crynobone opened this issue Jun 6, 2012 · 2 comments

Comments

@crynobone
Copy link

A proposal

    <?php

    Squi\Table::create('a-table-name', function ($table) {
        $table->with(User::paginate(30));

        // indicate table has a pagination. default is false
        $table->paginate = true;

        $table->attr('id', 'give-a-table-id');
        $table->attr = array('class' => 'table table-bordered');

        $table->column('id'); // Header as Id, and value from $row->id;

        // Add another column
        $table->column(function ($column, $row)
        {
            $column->name  = 'Name';
            $column->value = $row->name;
            $column->attr  = array('style' => 'width:100%');
        });
    });

    // echo table
    echo Squi\Table::render('a-table-name');
@kbanman
Copy link
Owner

kbanman commented Jun 6, 2012

Very cool.

Why named though? I would expect the table to be constructed in a controller, so I would rather just store it in a variable.

Also, what part would the class play in pagination?

@crynobone
Copy link
Author

  1. We can simplify it to without it, a name would allow it to be modified, but we can also ignore it :)
  2. Since User::paginate(30); is requested inside Squi\Table closure, it would be better if Squi\Table can also handle pagination rendering (this would avoid having to have multiple call to User::paginate(30). There are other option that we can look into.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants