season in countries

This commit is contained in:
salam committed 2026-06-15 15:41:40 +02:00
1 parent ff4a4d9544
commit 0b9e99e844
4 files changed
+52 -12

No files matched your search

@@ -6,9 +6,12 @@ use App\Filament\Clusters\StaticData\Resources\Countries\Pages\ManageCountries;
use App\Filament\Clusters\StaticData\StaticDataCluster;
use App\Filament\Exports\CountryExporter;
use App\Models\Country;
use Filament\Actions\BulkAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\EditAction;
use Filament\Actions\ExportAction;
use Filament\Actions\Exports\Enums\ExportFormat;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Resources\Resource;
@@ -21,6 +24,7 @@ use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
class CountryResource extends Resource
{
@@ -44,6 +48,11 @@ class CountryResource extends Resource
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)',
])
]);
}
@@ -60,6 +69,13 @@ class CountryResource extends Resource
->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 {
@@ -77,7 +93,7 @@ class CountryResource extends Resource
Filter::make('icon')
->label('Missing Icons')
->query(fn (Builder $query): Builder => $query->whereNull('icon')),
->query(fn(Builder $query): Builder => $query->whereNull('icon')),
], layout: FiltersLayout::AboveContent)
->deferFilters(false)
->headerActions([
@@ -90,7 +106,7 @@ class CountryResource extends Resource
->modalIcon('phosphor-microsoft-excel-logo')
->exporter(CountryExporter::class)
->columnMapping(false)
->modifyQueryUsing(fn (Builder $query) => $query->where('is_country', true))
->modifyQueryUsing(fn(Builder $query) => $query->where('is_country', true))
->formats([
ExportFormat::Xlsx,
ExportFormat::Csv,
@@ -98,6 +114,26 @@ class CountryResource extends Resource
])
->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)',
])
]),
]),
]);
}
+12 -10
View File
@@ -13,7 +13,7 @@ class ImportEvents
{
$now = now()->format('Y-m-d H:i:s');
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
SimpleExcelReader::create(storage_path('app/public/' . $filePath))
->getRows()
->chunk(1000)
->each(function (LazyCollection $chunk) use ($now, $importmode) {
@@ -31,14 +31,15 @@ class ImportEvents
3 => 1661
4 => 4781
*/
StatistikoEvent::updateOrCreate([
'match_id' => (int) $row[0],
'sport_id' => (int) $row[1],
'league_id' => (int) $row[2],
'home_id' => (int) $row[3],
'away_id' => (int) $row[4],
'starttime' => Carbon::parse($row[5])->toIso8601String(),
],
StatistikoEvent::updateOrCreate(
[
'match_id' => (int) $row[0],
'sport_id' => (int) $row[1],
'league_id' => (int) $row[2],
'home_id' => (int) $row[3],
'away_id' => (int) $row[4],
'starttime' => Carbon::parse($row[5])->toIso8601String(),
],
[
'season' => (int) $row[6],
'gls_h' => (int) $row[7],
@@ -62,7 +63,8 @@ class ImportEvents
'result_code' => $row[25], // w, d, l
'created_at' => $now,
'updated_at' => $now,
]);
]
);
// StatistikoEvent::where('match_id', (int) $row[0])
// ->where('sport_id', (int) $row[1])
+1
View File
@@ -13,6 +13,7 @@ class Country extends Model
'iso2',
'iso3',
'cc',
'season_mode',
'is_country',
'disabled',
];
@@ -20,6 +20,7 @@ return new class extends Migration
$table->string('cc')->nullable();
$table->boolean('is_country')->default(0);
$table->boolean('disabled')->default(0);
$table->string('season_mode')->nullable();
$table->timestamps();
});
}