PHP code example of seblhaire / tablebuilder
1. Go to this page and download the library: Download seblhaire/tablebuilder 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/ */
seblhaire / tablebuilder example snippets
'providers' => [
...
Seblhaire\TableBuilder\TableBuilderHelperServiceProvider::class,
...
],
'aliases' => [
...
"TableBuilderHelper" => Seblhaire\TableBuilder\TableBuilderHelper::class
]
sh
$ php artisan vendor:publish
$oTable = TableBuilderHelper::initTable('tabtest', route("tabletest"), [
'buttons' => [['id' => 'toto', 'em' => 'fas fa-search', 'action' => "multiselect", 'text' => 'Test multselect']],
'itemsperpage' => 20,
'eltsPerPageChngCallback' => 'eltspagechanged',
'aftertableload' => 'aftertableload'
]);
...
return view('tablebuilder::example', array('oTable' => $oTable));
public function loadTable(Request $request){
$oTable = TableBuilderHelper::initDataBuilder($request);
$wherefn = function ($data){
return (strpos($data['code'], $this->searchTerm) !== false) ||
(strpos($data['country'], $this->searchTerm) !== false);
}
$oTable->setSearchFunction($wherefn);
$oTable->addMethodToDisplay(config('tablebuilder.table.rowcontextualtrigger'), function($user){
if ($user->wage > 10000){
return 'table-danger';
}
return '';
});
$oTable->addMethodToDisplay('actions', function($user){
$actions = [['em' => 'far fa-edit', 'text' => 'Edit user, 'js' => "loaduser"]];
if ( ... ){
$actions[] = [....];
}else{
$actions[] =[ ... ];
}
return $actions;
});