79 lines
2.7 KiB
PHP
79 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Shifts\Tables;
|
|
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Actions\ForceDeleteBulkAction;
|
|
use Filament\Actions\RestoreBulkAction;
|
|
use Filament\Actions\ViewAction;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\TernaryFilter;
|
|
use Filament\Tables\Filters\TrashedFilter;
|
|
use Filament\Tables\Table;
|
|
|
|
class ShiftsTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('name')
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('code')
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('starts_at')
|
|
->label('Starts')
|
|
->time()
|
|
->sortable(),
|
|
TextColumn::make('ends_at')
|
|
->label('Ends')
|
|
->time()
|
|
->sortable(),
|
|
TextColumn::make('description')
|
|
->limit(50)
|
|
->toggleable(),
|
|
TextColumn::make('is_active')
|
|
->label('Status')
|
|
->badge()
|
|
->formatStateUsing(fn (bool $state): string => $state ? 'Active' : 'Inactive')
|
|
->color(fn (bool $state): string => $state ? 'success' : 'danger')
|
|
->sortable(),
|
|
TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
TextColumn::make('updated_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
TextColumn::make('deleted_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->filters([
|
|
TernaryFilter::make('is_active')
|
|
->label('Status')
|
|
->placeholder('All shifts')
|
|
->trueLabel('Active')
|
|
->falseLabel('Inactive'),
|
|
TrashedFilter::make(),
|
|
])
|
|
->recordActions([
|
|
ViewAction::make(),
|
|
EditAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
ForceDeleteBulkAction::make(),
|
|
RestoreBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|