components([ TextInput::make('name')->required(), TextInput::make('icon'), TextInput::make('iso2')->maxLength(2), TextInput::make('iso3')->maxLength(3), TextInput::make('cc'), TextInput::make('numeric'), Toggle::make('is_country'), Toggle::make('disabled')->label('Disable')->aboveLabel(['Hide in this table']), ]); } public static function table(Table $table): Table { return $table ->striped() ->recordAction(null) ->recordTitleAttribute('name') ->columns([ TextColumn::make('id')->searchable(), IconColumn::make('icon') ->sortable() ->icon(function ($state): string { return $state; })->label('Flags')->size(IconSize::TwoExtraLarge), TextColumn::make('name') ->searchable() ->copyable() ->copyMessage('Name copied') ->copyMessageDuration(1500), // TextColumn::make('iso2'), TextColumn::make('iso3'), TextColumn::make('cc'), TextColumn::make('numeric'), IconColumn::make('is_country')->alignCenter()->boolean(), ]) ->defaultSort('name', direction: 'asc') ->filters([ TernaryFilter::make('is_country'), Filter::make('icon') ->label('Missing Icons') ->query(fn (Builder $query): Builder => $query->whereNull('icon')), ]) ->recordActions([ EditAction::make()->hiddenLabel(), ]); } public static function getNavigationBadge(): ?string { return parent::getEloquentQuery()->where('disabled', false)->count(); } public static function getEloquentQuery(): Builder { return parent::getEloquentQuery()->where('disabled', false); } public static function getPages(): array { return [ 'index' => ManageCountries::route('/'), ]; } }