schema([ Forms\Components\TextInput::make('name') ->required() ->placeholder("ex: 2024/2025") ->maxLength(255), Forms\Components\Toggle::make('is_active') ->required(), Forms\Components\DatePicker::make('start_date'), Forms\Components\DatePicker::make('end_date'), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('name') ->searchable() ->weight(fn (AcademicYear $record) => $record->is_active ? 'bold' : 'normal') ->color(fn (AcademicYear $record) => $record->is_active ? 'success' : null), Tables\Columns\IconColumn::make('is_active') ->boolean(), Tables\Columns\TextColumn::make('start_date') ->date() ->sortable(), Tables\Columns\TextColumn::make('end_date') ->date() ->sortable(), Tables\Columns\TextColumn::make('created_at') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), Tables\Columns\TextColumn::make('updated_at') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), Tables\Columns\TextColumn::make('deleted_at') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), ]) ->filters([ Tables\Filters\TrashedFilter::make(), ]) ->actions([ Tables\Actions\EditAction::make(), Tables\Actions\Action::make('toggleActive') ->label('Toggle Active') ->icon('heroicon-o-power') ->action(function (AcademicYear $record) { // If setting to active, deactivate all others if ($record->is_active) { Notification::make() ->title('Info') ->body('The school year is active') ->info() ->send(); } else { AcademicYear::where('is_active', true)->update(['is_active' => false]); $record->update(['is_active' => true]); } }), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), Tables\Actions\ForceDeleteBulkAction::make(), Tables\Actions\RestoreBulkAction::make(), ]), ]) ->emptyStateActions([ Tables\Actions\CreateAction::make(), ]); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListAcademicYears::route('/'), 'create' => Pages\CreateAcademicYear::route('/create'), 'edit' => Pages\EditAcademicYear::route('/{record}/edit'), ]; } public static function getEloquentQuery(): Builder { return parent::getEloquentQuery() ->withoutGlobalScopes([ SoftDeletingScope::class, ]); } public static function getNavigationLabel(): string { return 'Tahun Ajaran'; } public static function getBreadcrumb(): string { return 'Tahun Ajaran'; } public static function getPluralModelLabel(): string { return 'Tahun Ajaran'; } }