Refer to the repo main Readme for install and basic usage
wire-table
requires PHP >= 8.0 and Laravel >= 9.0
composer require livewire/livewire:^2.0 tiknil/wire-table
Create a new component using the make:wiretable
command:
php artisan make:wiretable UsersTable
The UsersTable class will be created inside your app/Livewire
folder.
A basic table:
class UsersTable extends WireTable
{
public function query(): Builder
{
return User::query();
}
public function columns(): array
{
return [
Column::create(
label: __('backend.created_at'),
key: 'created_at',
sort: true
),
Column::create(
label: __('backend.name'),
key: 'name',
sort: true
),
Column::create(
label: __('backend.email'),
key: 'email',
sort: true
),
];
}
}
Some customization require you to publish the wire table files.
php artisan vendor:publish --tag=wiretable:config # Config file
php artisan vendor:publish --tag=wiretable:views # Blade views
php artisan vendor:publish --tag=wiretable:lang # Lang translation files
When you publish view files, you probably only need to edit the view inside a specific theme folder. It's recommended to delete from your
resources/views/vendor
folder the files you don't need to edit, especially the corecomponent.blade.php
file.