components([ Select::make('classification_id') ->label('Klasifikasi') ->options(Classification::query()->active()->pluck('name', 'id')) ->searchable() ->native(false) ->required() ->rules(['exists:classifications,id']) ->autofocus(), TextInput::make('name') ->label('Nama') ->placeholder('Korupsi') ->autocomplete(false) ->required() ->maxLength(50), ]) ->columns(1); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('classification.name') ->label('Klasifikasi') ->searchable() ->sortable(), TextColumn::make('name') ->label('Nama') ->searchable() ->sortable(), ToggleColumn::make('is_active') ->label('Aktif?') ->sortable() ->getStateUsing(fn (SubClassification $record): bool => $record->is_active === IsActive::ACTIVE) ->updateStateUsing(function (SubClassification $record, bool $state): void { $record->is_active = $state ? IsActive::ACTIVE : IsActive::INACTIVE; $record->save(); Notification::make() ->title('Status Berubah! 🔄✨') ->body('Status data berhasil diperbarui. Perubahan langsung aktif ya! 👍') ->success() ->send(); }), ...TimestampColumns::make(), ]) ->filters([ TrashedFilter::make() ->native(false) ->visible(fn () => auth()->user()?->hasRole('Developer')), ]) ->recordActions([ EditAction::make() ->modalWidth(Width::Large), DeleteAction::make(), ForceDeleteAction::make(), RestoreAction::make(), ]) ->toolbarActions([ BulkActionGroup::make([ ...DefaultBulkActions::make('Sub Klasifikasi'), ]), ]) ->emptyStateIcon(Heroicon::QueueList) ->emptyStateDescription('Setelah Anda membubat data pertama, maka akan muncul disini.') ->defaultSort('created_at', 'desc') ->deferFilters(false) ->reorderable('sort_order'); } public static function getPages(): array { return [ 'index' => ManageSubClassifications::route('/'), ]; } public static function getRecordRouteBindingEloquentQuery(): Builder { return parent::getRecordRouteBindingEloquentQuery() ->withoutGlobalScopes([ SoftDeletingScope::class, ]); } }