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']), Select::make('season_mode') ->options([ 'halfyear' => 'Half Year (25/26)', 'fullyear' => 'Full Year (2026)', ]) ]); } 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(), TextColumn::make('season_mode') ->badge() ->formatStateUsing(fn(string $state): string => strtoupper($state)) ->color(fn(string $state): string => match ($state) { 'halfyear' => 'warning', 'fullyear' => 'success', }), 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(), ])->toolbarActions([ BulkActionGroup::make([ BulkAction::make('season_mode') ->icon('phosphor-calendar') ->action(function (Collection $records, array $data): void { foreach ($records as $record) { Country::where('id', '=', $record->id) ->update( ['season_mode' => $data['season_mode']] ); } }) ->schema([ Select::make('season_mode') ->options([ 'halfyear' => 'Half Year (25/26)', 'fullyear' => 'Full Year (2026)', ]) ]), ]), ]); } 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('/'), ]; } }