PHP code example of tranquil-tools / laravel-vue-table-builder
1. Go to this page and download the library: Download tranquil-tools/laravel-vue-table-builder 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/ */
tranquil-tools / laravel-vue-table-builder example snippets
use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use TranquilTools\TableBuilder\AbstractTable;
use TranquilTools\TableBuilder\TableBuilder;
class UsersTable extends AbstractTable
{
public function for(): Builder
{
return User::query();
}
public function configure(TableBuilder $table)
{
$table
->defaultSort('name')
->withGlobalSearch(columns: ['name', 'email'])
->column('id', 'ID')
->column('name', 'Name', sortable: true)
->column('email', 'Email', sortable: true)
->column('created_at', 'Created', sortable: true)
->paginate(25);
}
}
use Inertia\Inertia;
public function index()
{
return Inertia::render('Users/Index', [
'table' => \App\Tables\UsersTable::build(),
]);
}
bash
php artisan vendor:publish --tag="vue-table-builder-config"