Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mfrouh/datatable-livewire
Laravel Livewire Datatable
https://github.com/mfrouh/datatable-livewire
alpinejs laravel laravel-package livewire livewire-datatables php tailwind
Last synced: 25 days ago
JSON representation
Laravel Livewire Datatable
- Host: GitHub
- URL: https://github.com/mfrouh/datatable-livewire
- Owner: mfrouh
- Created: 2021-05-24T23:41:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-09T00:17:28.000Z (over 3 years ago)
- Last Synced: 2024-09-30T04:41:30.734Z (about 1 month ago)
- Topics: alpinejs, laravel, laravel-package, livewire, livewire-datatables, php, tailwind
- Language: PHP
- Homepage:
- Size: 31.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Package DataTable Livewire
```
composer require mfrouh/datatable-livewire
```This package was built using
[Laravel](https://laravel.com)
and [livewire](https://laravel-livewire.com)
and [tailwind](https://tailwindcss.com)
and [alpinejs](https://github.com/alpinejs/alpine)## Create Livewire DataTable
```php
php artisan make:datatable user
``````php
php artisan make:datatable backend.user
``````php
php artisan make:datatable backend/user
```will be save in the folder App\Http\livewire\DataTables
## Add In Blade
```blade
@livewire('datatable.backend.user') for backend.user
@livewire('datatable.admin.backend.user') for admin/backend/user
```> backend\user will be App\Http\livewire\DataTables\Backend\User.php
>
> backend.user will be App\Http\livewire\DataTables\Backend\User.php
>
> user will be App\Http\livewire\DataTables\User.php## Code DataTable
```php
model::query();
}/**
* 'method_name or route()' => 'permission',
* ex 'create' => 'create post',
*
*/
public array $tablePermissions = [];/**
* add columns in array
*
*/
public function columns(): array
{
return [];
}/**
* add actions in array
*
*/
public function actions(): array
{
return [];
}
}
```## Actions
```php
public function actions(): array
{
return [
Action::header()->events(['action' => 'label']),
Action::header()->urls(['action' => 'label']),
Action::action()->events(['action' => 'label']),
Action::action()->urls(['action' => 'label'])
];
}
```## Columns
>['TextColumn','NumberColumn','ImageColumn','PriceColumn',
>'DateTimeColumn','LabelColumn','LangColumn','MinuteColumn',
>'PercentageColumn']```php
public function columns(): array
{
return [
TextColumn::name('name')->label('label')->sortable()->searchable(),
NumberColumn::name('name')->label('label')->sortable()->searchable(),
MinuteColumn::name('name')->label('label')->sortable()->searchable(),
PercentageColumn::name('name')->label('label')->sortable()->searchable(),
LangColumn::name('name')->filename('filename')->label('label'),
DateTimeColumn::name('name')->format(format')->label('label')->sortable()->searchable(),
];
}
```