1. Go to this page and download the library: Download advicepharma/tablegenerator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
advicepharma / tablegenerator example snippets
use Advicepharma\Tablegenerator\Tablegenerator;
use Advicepharma\Tablegenerator\Elements\Action;
use Advicepharma\Tablegenerator\Elements\Column;
use Advicepharma\Tablegenerator\Elements\ActionColumn;
use Spatie\QueryBuilder\QueryBuilder;
$users = QueryBuilder::for(App\Models\User::class);
$table = new Tablegenerator;
$table->query($users)
->paginate()
->addFilter()
->addSorts()
->table()
->addColumn(
[
(new Column)
->field('id')
->label('ID')
->filtrable()
->sortable(),
(new Column)
->field('name')
->label('Name')
->filtrable()
]
);
$table->->table()
->addColumn(
[
(new Column)
->field('name')
->label('Name'),
(new Column)
->field('email')
->label('Email')
]
)
$table->->table()
->addColumn(
(new Column)
->field('name')
->filterKey('name')
->label('Name')
->filtrable()
->sortable()
)
(new ActionColumn)
->label('')
->addAction(
(new Action)
->type(Action::ACTION_EDIT)
->properties(
[
'link_to' => '/account/users/#id#'
]
)
)
->addAction(
(new Action)
->type(Action::ACTION_DELETE)
->properties(
[
'confirm' => true,
'confirm_message' => 'Do you really want to delete this user?',
'link_to' => route('user.destroy', '#id#', false)
]
)
)