2017 © Pedro Peláez
 

library suitable

Semantic-UI table builder for Laravel application

image

laravolt/suitable

Semantic-UI table builder for Laravel application

  • Friday, July 27, 2018
  • by uyab
  • Repository
  • 5 Watchers
  • 8 Stars
  • 1,845 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 27 Versions
  • 3 % Grown

The README.md

SUI-TABLE

Semantic-UI table builder for Laravel., (*1)

Version Compatibility

Laravel Suitable
5.2.x 1.x
5.3.x 2.x
5.4.x 2.x
5.5.x 2.x
5.6.x 2.x
5.7.x 2.x
5.8.x 3.x

Installation

Install Package

``` bash composer require laravolt/suitable, (*2)


### Service Provider _Skip this step for Laravel >= 5.5._ ```php Laravolt\Suitable\ServiceProvider::class,

Facade

Skip this step for Laravel >= 5.5., (*3)

'Suitable'  => Laravolt\Suitable\Facade::class,

Usage

Basic

{!! Suitable::source(User::all())
->columns([
    \Laravolt\Suitable\Columns\Numbering::make('No'),
    ['header' => 'Nama', 'field' => 'name'],
    ['header' => 'Email', 'field' => 'email'],
])
->render() !!}

Columns Definition

field

{!! Suitable::source(User::all())
->columns([
    ['header' => 'Email', 'field' => 'email'],
    ['header' => 'Bio', 'field' => 'profile.bio'], // nested attribute
])
->render() !!}`

view

{!! Suitable::source(User::all())
->columns([
    ['header' => 'Address', 'view' => 'components.address'],
])
->render() !!}`

views/components/address.blade.php, (*4)

<address>
  Address:<br>
  {{ $data->address_1 }}<br>
  {{ $data->address_2 }}<br>
  {{ $data->city }}, {{ $data->state }}
</address>

raw

{!! Suitable::source(User::all())
->columns([
    [
        'header' => 'Roles', 
        'raw' => function($data){
            // do anything here and don't forget to return String
            return $data->roles->implode('name', ', '); // output: "role1, role2, role3"
        }
    ],
])
->render() !!}`

ColumnInterface

{!! Suitable::source(User::all())
->columns([
    new \App\Columns\StatusColumn('Status'),
])
->render() !!}
Contract
<?php
namespace Laravolt\Suitable\Columns;

interface ColumnInterface
{
    public function header();

    public function headerAttributes();

    public function cell($cell, $collection, $loop);

    public function cellAttributes($cell);

    public function sortable();
}
Implementation

StatusColumn.php, (*5)

<?php

namespace App\Columns;

use Laravolt\Suitable\Columns\ColumnInterface;

class StatusColumn implements ColumnInterface
{
    protected $header;

    public function __construct($header)
    {
        $this->header = $header;
    }

    public function header()
    {
        return $this->header;
    }

    public function cell($cell, $collection, $loop)
    {
        return sprintf("<div class='ui label'>%s</div>", $cell->status);
    }

    public function headerAttributes()
    {
        return [];
    }

    public function cellAttributes($cell)
    {
        return [];
    }
}

Advance Usage

Auto Detect

<?php

namespace App\Http\Controllers;

use App\User;
use Illuminate\Routing\Controller;
use Laravolt\Suitable\Plugins\Pdf;
use Laravolt\Suitable\Plugins\Spreadsheet;
use Laravolt\Suitable\Tables\BasicTable;

class SuitableController extends Controller
{
    public function __invoke()
    {
        $table = (new BasicTable(new User()));

        return $table->view('etalase::example.suitable');
    }
}

Custom TableView

TableView Definition

<?php

namespace App\Table;

use Laravolt\Suitable\Columns\Date;
use Laravolt\Suitable\Columns\DateTime;
use Laravolt\Suitable\Columns\Id;
use Laravolt\Suitable\Columns\Numbering;
use Laravolt\Suitable\Columns\Text;
use Laravolt\Suitable\TableView;

class UserTable extends TableView
{
    protected function columns()
    {
        return [
            Numbering::make('No'),
            Id::make('id'),
            Text::make('name'),
            Text::make('email'),
            Date::make('created_at'),
            DateTime::make('updated_at'),
        ];
    }
}
<?php

namespace Laravolt\Etalase\Http\Controllers;

use App\User;
use Illuminate\Routing\Controller;
use App\Table\UserTable;
use Laravolt\Suitable\Plugins\Pdf;
use Laravolt\Suitable\Plugins\Spreadsheet;

class SuitableController extends Controller
{
    public function __invoke()
    {
        $users = User::autoSort()->paginate(5);
        $userTable = new UserTable($users);

        $table = $userTable
            ->plugins([
                (new Pdf('users.pdf')),
                (new Spreadsheet('users.xls')),
            ]);

        return $table->view('etalase::example.suitable');
    }
}

Built In Columns

  1. Laravolt\Suitable\Columns\Avatar
  2. Laravolt\Suitable\Columns\Boolean
  3. Laravolt\Suitable\Columns\Checkall
  4. Laravolt\Suitable\Columns\Date
  5. Laravolt\Suitable\Columns\DateTime
  6. Laravolt\Suitable\Columns\Id
  7. Laravolt\Suitable\Columns\Image
  8. Laravolt\Suitable\Columns\Numbering
  9. Laravolt\Suitable\Columns\Raw
  10. Laravolt\Suitable\Columns\RestfulButton
  11. Laravolt\Suitable\Columns\Text
  12. Laravolt\Suitable\Columns\View

Roadmap

  • Rename TableView to Table
  • Rename Toolbars to Segment\Item
  • Rename DropdownFilter to DropdownLink

The Versions

27/07 2018

dev-master

9999999-dev https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

25/06 2018

2.5.5

2.5.5.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

26/10 2017

2.5.4

2.5.4.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

11/10 2017

2.5.3

2.5.3.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

29/09 2017

2.5.2

2.5.2.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

29/09 2017

2.5.1

2.5.1.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

30/05 2017

2.5.0

2.5.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

25/05 2017

2.4.1

2.4.1.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

25/05 2017

2.4.0

2.4.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

27/04 2017

2.3.0

2.3.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

01/02 2017

2.2.1

2.2.1.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

06/01 2017

2.2.0

2.2.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

22/09 2016

2.1.1

2.1.1.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

05/09 2016

5.2.x-dev

5.2.9999999.9999999-dev https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

05/09 2016

1.2.1

1.2.1.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

02/09 2016

2.1.0

2.1.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

02/09 2016

1.2.0

1.2.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

10/08 2016

1.1.1

1.1.1.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

02/08 2016

2.0.0

2.0.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

02/08 2016

1.1.0

1.1.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

02/08 2016

1.0.0

1.0.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

02/08 2016

1.0

1.0.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

01/08 2016

0.5

0.5.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

30/07 2016

0.4

0.4.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table semantic ui laravolt suitable

29/07 2016

0.3

0.3.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table laravolt suitable

19/07 2016

0.2

0.2.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table laravolt suitable

19/07 2016

0.1

0.1.0.0 https://github.com/laravolt/suitable

Semantic-UI table builder for Laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel crud table laravolt suitable