72 lines
2.2 KiB
PHP
72 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Clusters\Settings\Provinces\Tables;
|
|
|
|
use App\Modules\Region\Repositories\RegionRepository;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Filters\TernaryFilter;
|
|
use Filament\Tables\Table;
|
|
|
|
class ProvincesTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('name')
|
|
->label(__('Name'))
|
|
->searchable()
|
|
->sortable(),
|
|
|
|
TextColumn::make('region')
|
|
->label(__('Region'))
|
|
->formatStateUsing(fn (string $state): string => RegionRepository::label($state))
|
|
->searchable()
|
|
->sortable(),
|
|
|
|
IconColumn::make('active')
|
|
->label(__('Active'))
|
|
->boolean()
|
|
->sortable(),
|
|
|
|
TextColumn::make('created_at')
|
|
->label(__('Created At'))
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
|
|
TextColumn::make('updated_at')
|
|
->label(__('Updated At'))
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->filters([
|
|
SelectFilter::make('region')
|
|
->label(__('Region'))
|
|
->options(fn () => regions())
|
|
->native(false),
|
|
|
|
TernaryFilter::make('active')
|
|
->label(__('Active'))
|
|
->boolean()
|
|
->trueLabel(__('Active only'))
|
|
->falseLabel(__('Inactive only'))
|
|
->native(false),
|
|
])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|