Package Data | |
---|---|
Maintainer Username: | uyab |
Maintainer Contact: | bayu.hendra@javan.co.id (Bayu Hendra Winata) |
Package Create Date: | 2016-07-15 |
Package Last Update: | 2020-02-25 |
Home Page: | https://laravolt.dev |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-14 15:04:32 |
Package Statistics | |
---|---|
Total Downloads: | 15,364 |
Monthly Downloads: | 6 |
Daily Downloads: | 1 |
Total Stars: | 8 |
Total Watchers: | 4 |
Total Forks: | 5 |
Total Open Issues: | 6 |
Semantic-UI table builder for Laravel.
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
composer require laravolt/suitable
Skip this step for Laravel 5.5 or above.
Laravolt\Suitable\ServiceProvider::class,
Skip this step for Laravel 5.5 or above.
'Suitable' => Laravolt\Suitable\Facade::class,
{!! Suitable::source(User::all())
->id('table1')
->title('Users')
->tableClass('ui table')
->search(false)
->columns([
new \Laravolt\Suitable\Components\Checkall(),
['header' => 'Nama', 'field' => 'name'],
['header' => 'Email', 'field' => 'email'],
])
->render() !!}
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
<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() !!}
<?php
namespace Laravolt\Suitable\Columns;
interface ColumnInterface
{
public function header();
public function headerAttributes();
public function cell($cell, $collection, $loop);
public function cellAttributes($cell);
}
StatusColumn.php
<?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 [];
}
}