Skip to content

Laravel package extending Livewire to easily create useful tables

License

Notifications You must be signed in to change notification settings

tiknil/wire-table

Repository files navigation

Livewire extension for building tables

Latest Version on Packagist Total Downloads GitHub Actions

The aim of this project is to provide a useful boilerplate with sane defaults for building backoffice tables, while allowing easy customization.

Installation

wire-table requires PHP >= 8.1 and Laravel >= 10.0

composer require livewire/livewire:^3.0 tiknil/wire-table

Note

Since v1.0.0, wire-table requires livewire 3.0. Use v0.3.2 if you are supporting livewire 2

Optional you can publish wire-table files for further customization:

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

Usage

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
            ),
        ];
    }
}

Include it in your blade file:

<livewire:users-table />

Remember to include the livewire javascript and css in every page where you will be using it.

The tables are just livewire components, so the official livewire documentation applies here.

Features

See the docs folder for the full documentation.

Quick links:

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email balduzzi.giorgio@tiknil.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


This package was generated using the Laravel Package Boilerplate, following the laravelpackage.com documentation.