Workflow
Persist
XLSX
Csv
ID
Dish
Diet
Category
Price
Calories
In Stock
Production date
Action
ID
Dish
Diet
Category
Price
Calories
In Stock
Production date
Action
1
Arkansas Possum Pie
πŸ₯œ Suitable for Celiacs
Pie
849 kcal
28/03/2024
2
Albacore Tuna Melt
πŸ₯œ Suitable for Celiacs
Dessert
244 kcal
15/03/2024
3
Π±ΠΎΡ€Ρ‰
🌱 Suitable for Vegans
Fish
799 kcal
17/03/2024
4
Bacalhau com natas
πŸ₯œ Suitable for Celiacs
Garnish
749 kcal
01/04/2024
5
Baba Ghanoush
🌱 Suitable for Vegans
Pasta
692 kcal
01/04/2024
6
Bacon Cheeseburger
🌱 Suitable for Vegans
Pie
657 kcal
02/04/2024
7
Baked potato
🌱 Suitable for Vegans
Fish
764 kcal
06/03/2024
8
Baklava
🌱 Suitable for Vegans
Dessert
768 kcal
30/03/2024
9
Bangers and mash
🍽️ All diets
Meat
664 kcal
10/03/2024
10
Black Pudding
πŸ₯œ Suitable for Celiacs
Dessert
475 kcal
13/03/2024
Disclaimer: Table data is randomly generated for illustrative purposes only. The information here is not a reflection of the actual market and does not constitute business, financial, or medical advice.
open in GitHub
<?php
 
use App\Enums\Diet;
use App\Models\Category;
use App\Models\Chef;
use Illuminate\Database\Eloquent\Builder;
use PowerComponents\LivewirePowerGrid\Exportable;
use PowerComponents\LivewirePowerGrid\Facades\Filter;
use PowerComponents\LivewirePowerGrid\Footer;
use PowerComponents\LivewirePowerGrid\Header;
 
final class PersistTable extends DishesTable
{
public function setUp(): array
{
$this->persist(['columns', 'filters']);
 
return [
Exportable::make('export')
->striped()
->type(Exportable::TYPE_XLS, Exportable::TYPE_CSV),
 
Header::make()
->showToggleColumns()
->withoutLoading()
->showSearchInput(),
 
Footer::make()
->showPerPage()
->showRecordCount(),
];
}
 
public function header(): array
{
return [];
}
 
public function filters(): array
{
return [
Filter::inputText('dish_name', 'dishes.name'),
 
Filter::inputText('name')
->placeholder('Test')
->operators(['contains']),
 
Filter::boolean('in_stock', 'in_stock')
->label('In stock', 'Out of stock'),
 
Filter::enumSelect('diet', 'dishes.diet')
->dataSource(Diet::cases())
->optionLabel('dishes.diet'),
 
Filter::select('category_name', 'category_id')
->dataSource(Category::all())
->optionLabel('name')
->optionValue('id'),
 
Filter::select('chef_name', 'chef_id')
->depends(['category_id'])
->dataSource(fn ($depends) => Chef::query()
->when(isset($depends['category_id']),
fn (Builder $query) => $query->whereRelation('categories',
fn (Builder $builder) => $builder->where('id', $depends['category_id'])
)
)
->get()
)
->optionLabel('name')
->optionValue('id'),
 
Filter::number('price_BRL', 'price'),
 
Filter::datetimepicker('created_at_formatted', 'created_at')
->params([
'timezone' => 'America/Sao_Paulo',
]),
];
}
}

Here you can find all relevant packages installed on this demo.

Name
Version
Description
laravel/framework
v10
The Laravel Framework.
openspout/openspout
v4.23.0
PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way
power-components/livewire-powergrid
5.x-dev
PowerGrid generates Advanced Datatables using Laravel Livewire.