luckykenlin / livewire-tables
livewire-tables
Fund package maintenance!
luckykenlin
Installs: 1 965
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^8.1|^8.2
- illuminate/support: ^9.0|^10.0|^11.0
- livewire/livewire: ^v3.0.0-beta.1
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- brianium/paratest: ^v7.2.4
- laravel/framework: ^10.0|^11.0
- laravel/legacy-factories: ^v1.3.2
- nunomaduro/collision: ^v7.7.0
- orchestra/testbench: ^7.0|^8.0
- phpunit/phpunit: ^9.5.4
- vimeo/psalm: ^4.4
README
A dynamic livewire table component for laravel.
Requirements
Installation
You can install the package via composer:
composer require luckykenlin/livewire-tables
Documentation
https://luckykenlin.github.io/livewire-tables/
Usage
Creating 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;
Rendering the Table
Place the following where you want the table to appear.
<livewire:users-table />
To-do/Roadmap
- User Column Selection
- Bulk Actions
- Date Filter
- Selector Filter
- Multiple Selector Filter
- Bulk Actions
- CDN Css
- Test Suite
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.