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