Workflow
Dishes Detail Row
Id
Name
Action
1
Arkansas Possum Pie
2
Albacore Tuna Melt
3
борщ
4
Bacalhau com natas
5
Baba Ghanoush
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\Models\Dish;
use Illuminate\Database\Eloquent\Builder;
use PowerComponents\LivewirePowerGrid\Button;
use PowerComponents\LivewirePowerGrid\Column;
use PowerComponents\LivewirePowerGrid\Detail;
use PowerComponents\LivewirePowerGrid\Facades\Rule;
use PowerComponents\LivewirePowerGrid\Footer;
use PowerComponents\LivewirePowerGrid\Header;
use PowerComponents\LivewirePowerGrid\PowerGrid;
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\PowerGridFields;
 
class DishesDetailRowTable extends PowerGridComponent
{
public function setUp(): array
{
return [
Header::make()
->showSearchInput(),
 
Footer::make()
->showPerPage(5)
->showRecordCount(),
 
Detail::make()
->view('components.detail')
->params(['name' => 'Luan'])
->showCollapseIcon(),
];
}
 
public function datasource(): Builder
{
return $this->query();
}
 
public function query(): Builder
{
return Dish::with('category');
}
 
public function join(): Builder
{
return Dish::query()
->join('categories', function ($categories) {
$categories->on('dishes.category_id', '=', 'categories.id');
})
->select('dishes.*', 'categories.name as category_name');
}
 
public function fields(): PowerGridFields
{
return PowerGrid::fields()
->add('id')
->add('name');
}
 
public function columns(): array
{
return [
Column::make('Id', 'id')
->searchable()
->sortable(),
 
Column::make('Name', 'name')
->searchable()
->sortable(),
 
Column::action('Action'),
];
}
 
public function actions(): array
{
return [
Button::make('toggleDetail', 'Toggle Detail')
->class('text-center')
->toggleDetail(),
];
}
 
public function actionRules(): array
{
return [
Rule::rows()
->when(fn (Dish $dish) => $dish->id == 2)
->detailView('components.detail-rules', ['fromActionRule' => true]),
];
}
}

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.