Workflow
Searchableraw

Uses searchableRaw() to search for an existing date with the format dd/mm/YYYY.

ID
Dish
Production date
1
Arkansas Possum Pie
29/06/2024
2
Albacore Tuna Melt
05/07/2024
3
борщ
10/07/2024
4
Bacalhau com natas
07/07/2024
5
Baba Ghanoush
01/07/2024
6
Bacon Cheeseburger
17/06/2024
7
Baked potato
01/07/2024
8
Baklava
08/07/2024
9
Bangers and mash
21/06/2024
10
Black Pudding
19/06/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.
<?php
 
namespace App\Livewire\Examples\SearchablerawTable;
 
use App\Models\Dish;
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 SearchablerawTable extends PowerGridComponent
{
public string $sortField = 'dishes.id';
 
public function setUp(): array
{
$this->showCheckBox();
 
return [
Header::make()
->showSearchInput(),
 
Footer::make()
->showPerPage()
->showRecordCount(),
];
}
 
public function datasource(): ?Builder
{
return Dish::query()->select('dishes.*');
}
 
public function fields(): PowerGridFields
{
return PowerGrid::fields()
->add('id')
->add('dish_name', fn ($dish) => e($dish->name))
->add('produced_at')
->add('produced_at_formatted', fn ($dish) => Carbon::parse($dish->produced_at)->format('d/m/Y'));
}
 
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()
->sortable(),
 
Column::add()
->title('Production date')
->field('produced_at_formatted')
->searchableRaw('DATE_FORMAT(dishes.produced_at, "%d/%m/%Y")'),
];
}
}
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.