Files

35 lines
1.2 KiB
PHP

<?php
namespace App\Filament\Resources\Users\RelationManagers;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class AttendanceRelationManager extends RelationManager
{
protected static string $relationship = 'activities';
protected static ?string $title = 'Rekap Kehadiran';
public function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('title')->label('Kegiatan'),
TextColumn::make('start_date')->label('Tanggal')->date('d M Y')->sortable(),
TextColumn::make('pivot.status')->label('Status')
->badge()
->color(fn ($state) => match ($state) {
'hadir' => 'success',
'izin' => 'warning',
'alpha' => 'danger',
default => 'gray',
})
->formatStateUsing(fn ($state) => ucfirst($state ?? '-')),
TextColumn::make('pivot.notes')->label('Catatan')->placeholder('-'),
])
->defaultSort('activities.start_date', 'desc')
->paginated([10, 25]);
}
}