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() ->alignCenter()->tooltip('Click to copy'), TextColumn::make('name') ->searchable() ->color('primary') ->copyable(), IconColumn::make('icon') ->sortable() ->icon(function ($state): string { return $state; })->label('Flags')->size(IconSize::TwoExtraLarge), 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')), ], layout: FiltersLayout::AboveContent) ->deferFilters(false) ->headerActions([ ExportAction::make() ->modalHeading('Download Countries') ->label('Export') ->color('warning') ->icon('phosphor-download') ->modalDescription('This will download the Countries (id, name) from TxOdds.') ->modalIcon('phosphor-microsoft-excel-logo') ->exporter(CountryExporter::class) ->columnMapping(false) ->modifyQueryUsing(fn (Builder $query) => $query->where('is_country', true)) ->formats([ ExportFormat::Xlsx, ExportFormat::Csv, ]), ]) ->recordActions([ EditAction::make()->hiddenLabel(), ]); } public static function getNavigationBadge(): ?string { return parent::getEloquentQuery()->where('disabled', false)->count(); } public static function getNavigationBadgeColor(): ?string { return 'warning'; } public static function getEloquentQuery(): Builder { return parent::getEloquentQuery()->where('disabled', false); } public static function getPages(): array { return [ 'index' => ManageCountries::route('/'), ]; } }