Workflow
⚡️ PowerGrid 6 + daisyUI 5 theme
Filters Outside

This example shows Filters "Outside".

(This Table is a variation of the "Filter Inline" example.)

ID
Dish
Calories
Category
Chef
Price
Diet
In Stock
Created At
2
Albacore Tuna Melt
855 kcal
Soup
Vitor
R$ 145,93
🌱 Suitable for Vegans
Out of Stock
01/12/2024
Showing 1 to 1 of 1 Results
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\FiltersOutsideTable;

use App\Livewire\Examples\FiltersInlineTable\FiltersInlineTable;
use App\Models\Dish;
use Illuminate\Database\Eloquent\Builder;
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid;

final class FiltersOutsideTable extends FiltersInlineTable
{
    public string $tableName = 'filters-outside-table';

    public bool $showFilters = true;

    public function boot(): void
    {
        config(['livewire-powergrid.filter' => 'outside']);
    }

    public function setUp(): array
    {
        return [
            PowerGrid::header()
                ->showToggleColumns()
                ->withoutLoading()
                ->showSearchInput(),

            PowerGrid::footer()
                ->showPerPage()
                ->showRecordCount(),
        ];
    }

    public function datasource(): Builder
    {
        return Dish::query()
            ->when(
                $this->categoryId,
                fn ($builder) => $builder->whereHas(
                    'category',
                    fn ($builder) => $builder->where('category_id', $this->categoryId)
                )
                    ->with(['category', 'kitchen'])
            );
    }
}