schema([ TextInput::make('name')->required()->maxLength(120), Select::make('country_id')->relationship('country', 'name')->label('Country')->searchable()->preload()->required(), Toggle::make('is_active')->default(true), ]); } public static function table(Table $table): Table { return $table->columns([ TextColumn::make('id')->sortable(), TextColumn::make('name')->searchable()->sortable(), TextColumn::make('country.name')->label('Country')->searchable()->sortable(), TextColumn::make('districts_count')->counts('districts')->label('Districts')->sortable(), IconColumn::make('is_active')->boolean(), TextColumn::make('created_at')->dateTime()->sortable()->toggleable(isToggledHiddenByDefault: true), ])->defaultSort('id', 'desc')->filters([ SelectFilter::make('country_id') ->label('Country') ->relationship('country', 'name') ->searchable() ->preload(), TernaryFilter::make('is_active')->label('Active'), ])->actions([ EditAction::make(), Action::make('activities') ->icon('heroicon-o-clock') ->url(fn (City $record): string => static::getUrl('activities', ['record' => $record])), DeleteAction::make(), ]); } public static function getPages(): array { return [ 'index' => Pages\ListCities::route('/'), 'create' => Pages\CreateCity::route('/create'), 'activities' => Pages\ListCityActivities::route('/{record}/activities'), 'edit' => Pages\EditCity::route('/{record}/edit'), ]; } }