Workflow
Enum
ID
Dish
Diet
ID
Dish
Diet
1
Arkansas Possum Pie
πŸ₯œ Suitable for Celiacs
2
Albacore Tuna Melt
πŸ₯œ Suitable for Celiacs
3
Π±ΠΎΡ€Ρ‰
🌱 Suitable for Vegans
4
Bacalhau com natas
πŸ₯œ Suitable for Celiacs
5
Baba Ghanoush
🌱 Suitable for Vegans
6
Bacon Cheeseburger
🌱 Suitable for Vegans
7
Baked potato
🌱 Suitable for Vegans
8
Baklava
🌱 Suitable for Vegans
9
Bangers and mash
🍽️ All diets
10
Black Pudding
πŸ₯œ Suitable for Celiacs
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\Dish;
use Illuminate\Database\Eloquent\Builder;
use PowerComponents\LivewirePowerGrid\Column;
use PowerComponents\LivewirePowerGrid\Facades\Filter;
use PowerComponents\LivewirePowerGrid\Footer;
use PowerComponents\LivewirePowerGrid\Header;
use PowerComponents\LivewirePowerGrid\PowerGrid;
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\PowerGridFields;
 
class EnumTable extends PowerGridComponent
{
public bool $filtersOutside = false;
 
public string $sortField = 'dishes.id';
 
public bool $ableToLoad = false;
 
public string $loadingComponent = 'components.my-custom-loading';
 
public function setUp(): array
{
$this->showCheckBox();
 
return [
Header::make()
->showToggleColumns()
->showSearchInput(),
 
Footer::make()
->showPerPage()
->showRecordCount(),
];
}
 
public function datasource(): ?Builder
{
return Dish::query();
}
 
public function relationSearch(): array
{
return [
'category' => [
'name',
],
];
}
 
public function fields(): PowerGridFields
{
return PowerGrid::fields()
->add('id')
->add('dish_name', fn ($dish) => $dish->name)
->add('diet', fn ($dish) => \App\Enums\Diet::from($dish->diet)->labels());
}
 
public function columns(): array
{
return [
Column::add()
->title(__('ID'))
->field('id', 'dishes.id')
->searchable()
->sortable(),
 
Column::add()
->title(__('Dish'))
->field('dish_name', 'dishes.name')
->searchable()
->contentClasses('!whitespace-normal')
->placeholder('placeholder')
->sortable(),
 
Column::add()
->field('diet', 'dishes.diet')
->title(__('Diet')),
];
}
 
public function filters(): array
{
return [
Filter::enumSelect('diet', 'dishes.diet')
->dataSource(Diet::cases())
->optionLabel('dishes.diet'),
];
 
}
}

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.