2017 © Pedro Peláez
 

library laravel-html-table

Html table generator for laravel

image

lloricode/laravel-html-table

Html table generator for laravel

  • Monday, June 18, 2018
  • by lloricode
  • Repository
  • 0 Watchers
  • 4 Stars
  • 1,204 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 12 % Grown

The README.md

Laravel HTML Table

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads codecov, (*1)

Generate Html Table with data from array/object., (*2)

Installation

You can install the package via composer:, (*3)

composer require lloricode/laravel-html-table

Usage

Sample in view

$headers = ['col1', 'col2'];

$data = [
    [
        'Lloric', 'Garcia',
    ],
    [
        'Foo', 'Bar',
    ],
    [
        'Foo1', 'bar11',
    ],
    [
        'tst', 'tesss',
    ],
];

$attributes = 'class="table"';
// Or
$attributes = ['myclass' => 'test_val'];

{!! Table::generate($headers, $data) !!}

{!! Table::generate($headers, $data, $attributes) !!}

// Model way

{!! 
    Table::generateModel(
        ['Id', 'Name', 'Email'],  // Column for table
        'App\User' // Model
        ,['id', 'name', 'email'], // Fields from model
        0, // Pagination Limit, if 0 all will show
        'border="1"' // Attributes sample js/css
    ) 
!!}

{{ Table::links() }} // Generate this when limit is not 0

// then you can add a links

{!!
    Table::optionLinks('my.route.name')
        ->modelResult(function($query){  // you can add filter if you are using model generate
            $query->where('user_id', auth()->user()->id);
            return $query;
        })
        ->generateModel(
            ['Id', 'Name', 'Email'],  // Column for table
            'App\User' // Model
            ,['id', 'name', 'email'], // Fields from model
            5, // Pagination Limit, if 0 all will show
            'border="1"' // Attributes sample js/css
        ) 
!!}

// you can specify more args
// 1st route name, 2nd header label, and 3rd is the every row label
{!! 
    Table::optionLinks('my.route.name', 'my option', 'view')
        ->generateModel(
            ['Id', 'Name', 'Email'],  // Column for table
            'App\User' // Model
            ,['id', 'name', 'email'], // Fields from model
            5, // Pagination Limit, if 0 all will show
            'border="1"' // Attributes sample js/css
        ) 
!!}

This is all default values html tags

$attributes = [
    // Main Table
    'table' => '

', 'table_end' => '
', // Head 'head' => '<thead>', 'head_end' => '</thead>', 'head_row' => '<tr>', 'head_row_end' => '</tr>', 'head_cell' => '<th>', 'head_cell_end' => '</th>', // Data body 'body' => '<tbody>', 'body_end' => '</tbody>', 'body_row' => '<tr>', 'body_row_end' => '</tr>', 'body_cell' => '<td>', 'body_cell_end' => '</td>', // Alternative 'alt_body_row' => '<tr>', 'alt_body_row_end' => '</tr>', 'alt_body_cell' => '<td>', 'alt_body_cell_end' => '</td>', ]; {!! Table::generate($headers, $data, $attributes) !!}

Sample Output

<table myclass="test_val"><thead><tr><th>col1</th><th>col2</th></tr></thead><tbody><tr><td>Lloric</td><td>Garcia</td></tr><tr><td>Foo</td><td>Bar</td></tr><tr><td>Foo1</td><td>bar11</td></tr><tr><td>tst</td><td>tesss</td></tr></tbody></table>

Adding attributes in cell data

$header = ['Date', 'Description', 'Amount'];
$datas = [
    [
        ['data' => '1', 'scope' => 'row'],
        'Mark',
        'Otto',
    ],
    [
        ['data' => '2', 'scope' => 'row'],
        'foo',
        'varr',
    ],
];

{!! Table::generate($header, $datas, ['class'=>'table']) !!}



Date Description Amount
1 Mark Otto
2 foo varr

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently., (*4)

Contributing

Please see CONTRIBUTING for details., (*5)

Credits

License

The MIT License (MIT). Please see License File for more information., (*6)

The Versions

18/06 2018

dev-develop

dev-develop

Html table generator for laravel

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Lloric Mayuga Garcia

18/06 2018

dev-master

9999999-dev

Html table generator for laravel

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Lloric Mayuga Garcia

18/06 2018

v1.3.3

1.3.3.0

Html table generator for laravel

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Lloric Mayuga Garcia

28/02 2018

1.3.2

1.3.2.0

Html table generator for laravel

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Lloric Mayuga Garcia

25/02 2018

v1.3.1

1.3.1.0

Html table generator for laravel

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Lloric Mayuga Garcia

17/02 2018

v1.3.0

1.3.0.0

Html table generator for laravel

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Lloric Mayuga Garcia

10/01 2018

v1.2.5

1.2.5.0

Html table generator for laravel

  Sources   Download

MIT

by Lloric Mayuga Garcia

10/01 2018

1.2.4

1.2.4.0

Html table generator for laravel

  Sources   Download

MIT

by Lloric Mayuga Garcia

17/08 2017

v1.2.3

1.2.3.0

Html table generator for laravel

  Sources   Download

MIT

by Lloric Mayuga Garcia

17/08 2017

v1.2.2

1.2.2.0

Html table generator for laravel

  Sources   Download

MIT

by Lloric Mayuga Garcia

10/08 2017

v1.2.1

1.2.1.0

Html table generator for laravel

  Sources   Download

MIT

by Lloric Mayuga Garcia

21/07 2017

v1.2.0

1.2.0.0

Html table generator for laravel

  Sources   Download

MIT

by Lloric Mayuga Garcia

19/07 2017

v1.1.0

1.1.0.0

Html table generator for laravel

  Sources   Download

MIT

by Lloric Mayuga Garcia

19/07 2017

v1.0.0

1.0.0.0

Html table generator for laravel

  Sources   Download

MIT

by Lloric Mayuga Garcia