Detail
This example demonstrates a Row Detail loaded from a Blade View.
There is an Action Rule modifing the view only for Row #1.
ID
Name
Email
Created At
Action
ID
|
Name
|
Email
|
Created At
|
Action
|
|
1
|
Test User
|
test@example.com
|
17/07/2024 22:05:47
|
|
---|---|---|---|---|---|
|
2
|
Luan
|
luanfreitasdev@fakemail.com
|
27/07/2024 03:12:21
|
|
|
3
|
Daniel
|
dansysanalyst@fakemail.com
|
27/07/2024 03:12:21
|
|
|
4
|
Claudio
|
claudio@fakemail.com
|
27/07/2024 03:12:21
|
|
|
5
|
Vitor
|
vitao@fakemail.com
|
27/07/2024 03:12:21
|
|
|
6
|
Tio Jobs
|
tiojobs@fakemail.com
|
27/07/2024 03:12:21
|
|
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.
<?php namespace App\Livewire\Examples\DetailTable; use App\Models\User;use Illuminate\Database\Eloquent\Builder;use Illuminate\Support\Carbon;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; final class DetailTable extends PowerGridComponent{ public function setUp(): array { return [ Header::make() ->showToggleColumns() ->showSearchInput(), Footer::make() ->showPerPage() ->showRecordCount(), Detail::make() ->view('components.detail') ->showCollapseIcon() ->params(['name' => 'Luan']), ]; } public function datasource(): ?Builder { return User::query(); } public function fields(): PowerGridFields { return PowerGrid::fields() ->add('id') ->add('name') ->add('email') ->add('created_at_formatted', fn ($user) => Carbon::parse($user->created_at)->format('d/m/Y H:i:s')); } public function columns(): array { return [ Column::make('ID', 'id'), Column::make('Name', 'name') ->sortable() ->searchable(), Column::make('Email', 'email') ->sortable() ->searchable(), Column::make('Created At', 'created_at_formatted', 'created_at') ->searchable() ->sortable(), Column::action('Action'), ]; } public function actions(): array { return [ Button::add('detail') ->slot('Detail') ->class('bg-blue-500 text-white font-bold py-2 px-2 rounded') ->toggleDetail(), ]; } public function actionRules(): array { return [ Rule::rows() ->when(fn ($user) => $user->id == 1) ->detailView('components.detail-rules', ['test' => 1]), ]; }}
Code highlighting provided by Torchlight.dev
Here you can find all relevant packages installed on this demo.
Name
|
Version
|
Description
|
---|---|---|
laravel/framework
|
v11
|
The Laravel Framework.
|
livewire/livewire
|
v3.5.4
|
A front-end framework for Laravel.
|
openspout/openspout
|
v4.24.3
|
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.
|