Workflow
Custom Theme

This component uses a Custom Theme TailwindStriped.

You can find its source code in our GitHub Repository.

Header Top View - This is my property: foobar
ID
Name
Email
Created At
Header Bottom View - This is my property: foobar
ID
Name
Email
Created At
1
Test User
test@example.com
18/05/2024 12:58:29
2
Luan
luanfreitasdev@fakemail.com
20/05/2024 17:57:09
3
Daniel
dansysanalyst@fakemail.com
20/05/2024 17:57:09
4
Claudio
claudio@fakemail.com
20/05/2024 17:57:09
Footer Top View - This is my property: foobar
Footer Bottom View - This is my property: foobar
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\CustomThemeTable;
 
use App\Helpers\PowerGridThemes\TailwindStriped;
use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon;
use PowerComponents\LivewirePowerGrid\Column;
use PowerComponents\LivewirePowerGrid\Footer;
use PowerComponents\LivewirePowerGrid\Header;
use PowerComponents\LivewirePowerGrid\PowerGrid;
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\PowerGridFields;
 
final class CustomThemeTable extends PowerGridComponent
{
public string $someProperty = 'foobar';
 
public function setUp(): array
{
return [
Header::make()
->showToggleColumns()
->showSearchInput()
->includeViewOnTop('components.header.view-on-top')
->includeViewOnBottom('components.header.view-on-bottom'),
 
Footer::make()
->showPerPage(4)
->showRecordCount()
->includeViewOnTop('components.bottom.view-on-top')
->includeViewOnBottom('components.bottom.view-on-bottom')
->pagination('components.pagination'),
];
}
 
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'))
->add('updated_at_formatted', fn ($user) => Carbon::parse($user->updated_at)->format('d/m/Y H:i:s'));
}
 
public function columns(): array
{
return [
Column::add()
->title('ID')
->field('id'),
 
Column::add()
->title('Name')
->field('name')
->sortable()
->searchable(),
 
Column::add()
->title('Email')
->field('email')
->sortable()
->searchable(),
 
Column::add()
->title('Created At')
->field('created_at_formatted', 'created_at')
->searchable()
->sortable(),
 
];
}
 
public function template(): ?string
{
return TailwindStriped::class;
}
}
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.4.12
A front-end framework for Laravel.
openspout/openspout
v4.24.0
PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way
power-components/livewire-powergrid
v5.6.3
PowerGrid generates Advanced Datatables using Laravel Livewire.