A dynamic livewire table component for laravel.
You can install the package via composer:
composer require luckykenlin/livewire-tables
https://luckykenlin.github.io/livewire-tables/
To create a table component you draw inspiration from the below stub:
php artisan make:table UsersTable
To specific model use --model:
php artisan make:table UsersTable --model=User
<?php
namespace App\Http\Livewire;
use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Luckykenlin\LivewireTables\Views\Action;
use Luckykenlin\LivewireTables\Views\Column;
use Luckykenlin\LivewireTables\LivewireTables;
class UsersTable extends LivewireTables
{
public function query(): Builder
{
return User::query();
}
public function columns(): array
{
return [
Column::make('#', 'id')->sortable(),
Column::make('Name', 'name')->searchable()->sortable(),
Column::make('Email', 'email')->searchable()->sortable(),
Action::make()
];
}
}
Your component must implement two methods:
/**
* This defines the start of the query, usually Model::query() but can also eager load relationships and counts if needed.
*/
public function query() : Builder;
/**
* This defines the columns of the table, they don't necessarily have to map to columns on the database table.
*/
public function columns() : array;
Place the following where you want the table to appear.
<livewire:users-table />
- User Column Selection
- Bulk Actions
- Date Filter
- Selector Filter
- Multiple Selector Filter
- Bulk Actions
- CDN Css
- Test Suite
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.