2017 © Pedro Peláez
 

library laravel-tblist

Simple admin table listing for bootstrap 3 and laravel 4|5

image

nerweb/laravel-tblist

Simple admin table listing for bootstrap 3 and laravel 4|5

  • Thursday, December 11, 2014
  • by reillo
  • Repository
  • 4 Watchers
  • 7 Stars
  • 109 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

laravel-tblist

Simple admin table listing for bootstrap 3 and laravel 4|5, (*1)


Installation

Add the following to your composer.json file:, (*2)

"nerweb/laravel-tblist": "1.2.x"

Then, run composer update nerweb/laravel-tblist or composer install if you have not already installed packages., (*3)

and, (*4)

Publish assets:, (*5)

php artisan asset:publish nerweb/laravel-tblist

Simple Example

First, create a class name UserTblist., (*6)

use Nerweb\Tblist\BaseTblist;

class UserTblist extends BaseTblist {

    // set no result message
    public $noResults = "No User found.";

    function __construct()
    {
        $this->table = 'users';

        $this->setQuery();
        $this->setColumns();
    }

    protected function setQuery()
    {
        $this->query = User::where('active',1);
        $this->columnsToSelect = array('*');
    }

    protected function setColumns()
    {
        $this->addCheckableColumn();

        $this->columns['username'] = array(
            'label'     => 'Username',
            'sortable'  => true,
            'table_column'  => 'users.username',
        );

        $this->columns['email'] = array(
            'label'         => 'Email',
            'sortable'      => true,
            'classes'       => 'someclass someclass2',
            'table_column'  => 'users.email',
            'thead_attr'    => 'style="width:200px" data-someattr="example"',
        );

        $this->addActionColumn();
    }
}

Create a route and and its controller. insert below inside the controller method., (*7)

$list = new UserTblist();
$list->prepareList();

return View::make('users.index', array('list', $list));

Create the blade user/index.blade.php and insert below., (*8)

{{ Form:open(array(
    'action' => $list->getBaseURL(),
    'method' =>'get',
    'id' =>'user_tblist',
    'class' =>'tblist-form'
)) }}
{{ $list->getTableData() }}
{{ $list->getPagination() }}
{{ $list->getPaginationInfo() }}
{{ Form::close() }}

For complete example, see example folder., (*9)


API Reference

Note! Child class should always extend Nerweb\Tblist\BaseTblist., (*10)

Column

The column property accepts a data for column name as a key and column options as a value., (*11)

Column key

The column key may or may not exists in the result row. Column key also assumes as the name to be sorted., (*12)

Note! if column key doesn't exists in the result row, you should create a protected method colSetTheColumnName as custom column., (*13)

Column options

Options type Description
label string Column header label.
sortable bool Whether sortable or not.
table_column string if set, then use its value instead of the column key as the column name to sort (i.e roles.admin, users.admin).
classes string table column classes. Note! Both applied to header, footer and body column.
thead_attr string Table header attribute.

Note! All column option is default to null., (*14)

Custom Column Display

Add protected method colSetColumnNameToCamel (i.e colSetUsername, colSetCreatedAt) that only accepts 1 parameter an object of result row. Then echo or display the string., (*15)

Example

in your class, UserTblist for this example. Add this next to setColumns method, (*16)

protected function colSetUsername($row)
{
    echo Html::link("/users/{$row->id}/view", $row->username);
}

Custom Column

Sometimes we want to show column that is not in the result object row., (*17)

To do this, add a column key to columns property and make sure that the sortable options is set to false., (*18)

and, (*19)

create a method called colSetYourColumnName($row) that accepts result row., (*20)

Multiple Tblist

Sometimes we want to display multiple table listing on the same page., (*21)

To do this,, (*22)

  • on class initialization, in this case $list = new UserTblist(). Override base URL via $list->setBaseURL($url, $parameters) method.
  • set the tblist form action with $list->getBaseURL().
  • create the route with controller and return the json data of the tblist.

Demo

see simple demo here, (*23)

License

This project is open-sourced software licensed under the MIT license., (*24)

The Versions

11/12 2014

dev-master

9999999-dev

Simple admin table listing for bootstrap 3 and laravel 4|5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent table admin view listing

30/10 2014

v1.2.2

1.2.2.0

Simple admin table listing for bootstrap 3 and laravel 4|5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent table admin view listing

27/10 2014

v1.2.1

1.2.1.0

Simple admin table listing for bootstrap 3 and laravel 4|5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent table admin view listing

25/10 2014

v1.2.0

1.2.0.0

Simple admin table listing for bootstrap 3 and laravel 4|5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent table admin view listing

23/10 2014

v1.1.0

1.1.0.0

Simple admin table listing for bootstrap 3 and laravel 4|5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent table admin view listing

21/10 2014

v1.0.1

1.0.1.0

laravel simple admin table listing

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent table admin view listing

13/10 2014

v1.0.0

1.0.0.0

laravel simple admin table listing

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel table view listing tblist laravel-tblist