components([ Select::make('location_id') ->label('Lokasi') ->options(Location::query()->pluck('name', 'id')) ->searchable() ->native(false) ->required() ->rules(['exists:locations,id']), TextInput::make('name') ->label('Nama') ->placeholder('Nagri Kaler') ->autocomplete(false) ->autofocus() ->required() ->maxLength(50), ]) ->columns(1); } public static function table(Table $table): Table { return $table ->recordTitleAttribute('name') ->columns([ TextColumn::make('location.name') ->label('Lokasi') ->searchable() ->sortable(), TextColumn::make('name') ->label('Nama') ->searchable() ->sortable(), ToggleColumn::make('is_active') ->label('Aktif?') ->getStateUsing(fn (SubLocation $record) => $record->is_active === IsActive::ACTIVE) ->updateStateUsing(function (SubLocation $record, bool $state) { $record->is_active = $state ? IsActive::ACTIVE : IsActive::INACTIVE; $record->save(); }) ->sortable(), ...TimestampColumns::make(), ]) ->filters([ TrashedFilter::make()->native(false), ]) ->recordActions([ EditAction::make()->modalWidth('lg'), DeleteAction::make(), ForceDeleteAction::make(), RestoreAction::make(), ]) ->toolbarActions([ BulkActionGroup::make([ ...DefaultBulkActions::make('Sub Lokasi'), ]), ]) ->emptyStateIcon('heroicon-o-bookmark') ->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' => ManageSubLocations::route('/'), ]; } public static function getRecordRouteBindingEloquentQuery(): Builder { return parent::getRecordRouteBindingEloquentQuery() ->withoutGlobalScopes([ SoftDeletingScope::class, ]); } }