evelution87 / alpine-tables
Data tables for Laravel using Alpine JS
Installs: 24
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:JavaScript
Requires
- php: ^8.0
- ext-json: *
- evelution87/heroicons: ^2.0
- laravel/framework: ^9.0|^10.0|^11.0
- dev-master
- v0.9.52
- v0.9.51
- v0.9.50
- v0.9.49
- v0.9.48
- v0.9.47
- v0.9.46
- v0.9.45
- v0.9.44
- v0.9.43
- v0.9.42
- v0.9.41
- v0.9.40
- v0.9.39
- v0.9.38
- v0.9.37
- v0.9.36
- v0.9.35
- v0.9.34
- v0.9.33
- v0.9.32
- v0.9.31
- v0.9.30
- v0.9.29
- v0.9.28
- v0.9.27
- v0.9.26
- v0.9.25
- v0.9.24
- v0.9.23
- v0.9.22
- v0.9.21
- 0.9.20
- 0.9.19
- 0.9.18
- 0.9.17
- 0.9.16
- 0.9.15
- 0.9.14
- 0.9.13
- 0.9.12
- 0.9.11
- 0.9.10
- 0.9.9
- 0.9.8
- 0.9.7
- 0.9.6
- 0.9.5
- 0.9.4
- 0.9.3
- 0.9.2
- 0.9.1
- 0.9.0
- 0.5.0
This package is auto-updated.
Last update: 2024-11-03 06:41:00 UTC
README
This package provides a component for Laravel websites to embed data tables using AlpineJS and Tailwind CSS.
Installation
You can install the package via composer:
composer require evelution87/alpine-tables
The required assets must be published by running:
php artisan alpinetables:publish
Usage
Alpine Tables can be enabled for a controller by adding a trait to the controller.
use \Evelution\AlpineTables\Traits\HasAlpineTable;
You must include your own version of two functions:
alpineModel()
defines the Laravel model the table will be using.
Replace 'User' with the model the table will be working with.
public function alpineModel() { return User::class; }
alpineColumns()
defines the columns that will appear on the table.
(documentation to be added later)
public function alpineColumns() { return [ [ 'key' => 'name', 'label' => 'Name', ], ]; }
Optional:
alpineSearchColumns()
can be used to define the columns that can be searched. By default it returns a list of all columns defined by alpineColumns()
, but you might want to customise this.
Adding to a View
To insert a table into a view, you can use the <x-alpine-table>
blade component.
<x-alpine-table route="{{ route('ajax.alpine.example') }}" key="example"></x-alpine-table>
- The
route
attribute defines the AJAX route for loading table data. This route should be defined in yourroutes.php
file. Example:
Route::post('ajax/example' [ ExampleController::class, 'alpineRequest'] );
- The (optional)
key
attribute is used when saving settings such as filters to a user's local browser storage. Use a different key for each table to allow different filters to be saved. Alternatively you can use the same key to make the filters function across different tables.
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 craig@evelution.net instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.