wip fix
This commit is contained in:
1 parent
9bcd4432c6
commit
6f92f9e1d5
1209 files changed
+220940
No files matched your search
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatisticFixtures\StatisticFixturesResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateStatisticFixtures extends CreateRecord
|
||||
{
|
||||
protected static string $resource = StatisticFixturesResource::class;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatisticFixtures\StatisticFixturesResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditStatisticFixtures extends EditRecord
|
||||
{
|
||||
protected static string $resource = StatisticFixturesResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatisticFixtures\StatisticFixturesResource;
|
||||
use App\Models\StatisticFixtures;
|
||||
use DateTime;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListStatisticFixtures extends ListRecords
|
||||
{
|
||||
protected static string $resource = StatisticFixturesResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('starttime')
|
||||
->color('gray')
|
||||
->tooltip('Find events with wrong starttime')
|
||||
->icon('phosphor-magnifying-glass')
|
||||
->modalSubmitAction(false)
|
||||
->modalContent(function () {
|
||||
$events = StatisticFixtures::with('league')->with('home')->with('away')->where('starttime', '<', new DateTime('-10 years'))->get();
|
||||
return view('filament.pages.list-fixtures-starttime', ['events' => $events]);
|
||||
}),
|
||||
Action::make('truncate')
|
||||
->icon('phosphor-trash')
|
||||
->tooltip('Delete all events')
|
||||
->requiresConfirmation()
|
||||
->color('danger')
|
||||
->action(function () {
|
||||
StatisticFixtures::truncate();
|
||||
}),
|
||||
Action::make('remove_started')
|
||||
->icon('phosphor-trash')
|
||||
->tooltip('Delete events already started')
|
||||
->requiresConfirmation()
|
||||
->color('info')
|
||||
->action(function () {
|
||||
StatisticFixtures::where('starttime', '<', now())->delete();
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class StatisticFixturesForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('exp_home')->required(),
|
||||
TextInput::make('exp_away')->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Pages\ListStatisticFixtures;
|
||||
use App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Schemas\StatisticFixturesForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Tables\StatisticFixturesTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\StatisticFixtures;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class StatisticFixturesResource extends Resource
|
||||
{
|
||||
protected static ?string $model = StatisticFixtures::class;
|
||||
|
||||
protected static ?string $navigationLabel = 'Fixtures';
|
||||
|
||||
protected static ?string $modelLabel = 'Fixtures';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return StatisticFixturesForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return StatisticFixturesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListStatisticFixtures::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Tables;
|
||||
|
||||
use App\Actions\LoadStatisticFixturesLeaguesOptions;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class StatisticFixturesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
IconColumn::make('sport_id')
|
||||
->label('')
|
||||
->icon(fn(string $state): string => match ($state) {
|
||||
'1' => 'icon-soccerball',
|
||||
'2' => 'icon-icehockey',
|
||||
'3' => 'icon-basketball',
|
||||
'5' => 'icon-tennisball',
|
||||
}),
|
||||
IconColumn::make('league.sofascore_category.flag')
|
||||
->label('')
|
||||
->icon(function ($state): string {
|
||||
return $state;
|
||||
}),
|
||||
TextColumn::make('league.name')
|
||||
->label('League')
|
||||
->tooltip(fn($record) => $record->league_id)
|
||||
->sortable()
|
||||
->searchable()
|
||||
->description(
|
||||
fn($record) => $record->league->sofascore_category->name
|
||||
),
|
||||
TextColumn::make('starttime')->dateTime('Y-m-d H:i')
|
||||
->sortable(),
|
||||
TextColumn::make('home.ss_team_name')
|
||||
->tooltip(fn($record) => $record->home_id)
|
||||
->color('primary')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('away.ss_team_name')
|
||||
->tooltip(fn($record) => $record->away_id)
|
||||
->color('success')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('updated_at')->alignCenter()->date(),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('fixture_filters')
|
||||
->columns(3)
|
||||
->columnSpan(3)
|
||||
->schema([
|
||||
Select::make('sport_id')
|
||||
->default(1)
|
||||
->options(fn() => Sport::query()->where('is_active', 1)->pluck('name', 'id'))
|
||||
->selectablePlaceholder(false)
|
||||
->label('Sport')
|
||||
->live(),
|
||||
Select::make('league_id')
|
||||
->options(fn(Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sport_id')))
|
||||
->preload()
|
||||
->searchable()
|
||||
->columnSpan(2)
|
||||
->label('League'),
|
||||
])->query(function (Builder $query, array $data): Builder {
|
||||
return $query->when(
|
||||
$data['league_id'],
|
||||
function (Builder $query, $league_id) {
|
||||
$query->where('league_id', $league_id)->orderBy('league_id');
|
||||
}
|
||||
)->when(
|
||||
$data['sport_id'],
|
||||
function (Builder $query, $away_id) {
|
||||
$query->where('sport_id', (int) $away_id);
|
||||
}
|
||||
);
|
||||
}),
|
||||
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton(),
|
||||
DeleteAction::make()->iconButton(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user