wip del err
This commit is contained in:
1 parent
812736ca9a
commit
9bcd4432c6
1210 files changed
-220941
No files matched your search
-11
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoEvents\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatistikoEvents\StatistikoEventsResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateStatistikoEvents extends CreateRecord
|
||||
{
|
||||
protected static string $resource = StatistikoEventsResource::class;
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoEvents\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatistikoEvents\StatistikoEventsResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditStatistikoEvents extends EditRecord
|
||||
{
|
||||
protected static string $resource = StatistikoEventsResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoEvents\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatistikoEvents\StatistikoEventsResource;
|
||||
use App\Filament\Exports\EventsHistoryExporter;
|
||||
use App\Models\StatistikoEvent;
|
||||
use DateTime;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\ExportAction;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListStatistikoEvents extends ListRecords
|
||||
{
|
||||
protected static string $resource = StatistikoEventsResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ExportAction::make('download_all')
|
||||
->columnMapping(false)
|
||||
->exporter(EventsHistoryExporter::class)
|
||||
->label('Download')
|
||||
->fileName(fn(Export $export): string => 'events-history-' . date('d.m.Y-H.i') . "-{$export->getKey()}")
|
||||
->icon('phosphor-download'),
|
||||
Action::make('starttime')
|
||||
->color('gray')
|
||||
->tooltip('Find events with wrong starttime')
|
||||
->icon('phosphor-magnifying-glass')
|
||||
->modalSubmitAction(fn(Action $action) => $action->label('Delete all')
|
||||
->color('danger')
|
||||
->icon('heroicon-o-trash'))
|
||||
->modalContent(function () {
|
||||
$events = StatistikoEvent::with('league')->with('home')->with('away')->where('starttime', '<', new DateTime('-10 years'))->get();
|
||||
|
||||
return view('filament.pages.list-fixtures-starttime', ['events' => $events]);
|
||||
})->action(function () {
|
||||
$events = StatistikoEvent::with('league')->with('home')->with('away')->where('starttime', '<', new DateTime('-10 years'))->get();
|
||||
foreach ($events as $value) {
|
||||
StatistikoEvent::where('match_id', $value->match_id)->delete();
|
||||
}
|
||||
}),
|
||||
Action::make('truncate')
|
||||
->icon('phosphor-trash')
|
||||
->requiresConfirmation()
|
||||
->color('danger')
|
||||
->action(function () {
|
||||
StatistikoEvent::truncate();
|
||||
}),
|
||||
CreateAction::make()
|
||||
->label('New')
|
||||
->icon('phosphor-plus'),
|
||||
];
|
||||
}
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoEvents\Schemas;
|
||||
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class StatistikoEventsForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
DateTimePicker::make('starttime')->native(false),
|
||||
TextInput::make('season'),
|
||||
TextInput::make('gls_h'),
|
||||
TextInput::make('gls_a'),
|
||||
TextInput::make('crn_h'),
|
||||
TextInput::make('fls_h'),
|
||||
TextInput::make('ofs_h'),
|
||||
TextInput::make('snt_h'),
|
||||
TextInput::make('tsh_h'),
|
||||
TextInput::make('crd_h'),
|
||||
TextInput::make('crn_a'),
|
||||
TextInput::make('fls_a'),
|
||||
TextInput::make('ofs_a'),
|
||||
TextInput::make('snt_a'),
|
||||
TextInput::make('tsh_a'),
|
||||
TextInput::make('crd_a'),
|
||||
TextInput::make('exp_home'),
|
||||
TextInput::make('exp_away'),
|
||||
TextInput::make('exp_handicap'),
|
||||
TextInput::make('exp_total'),
|
||||
])->columns(4);
|
||||
}
|
||||
}
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoEvents;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatistikoEvents\Pages\ListStatistikoEvents;
|
||||
use App\Filament\Clusters\StaticData\Resources\StatistikoEvents\Schemas\StatistikoEventsForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\StatistikoEvents\Tables\StatistikoEventsTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\StatistikoEvent;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class StatistikoEventsResource extends Resource
|
||||
{
|
||||
protected static ?string $model = StatistikoEvent::class;
|
||||
|
||||
protected static ?string $navigationLabel = 'Events';
|
||||
|
||||
protected static ?string $modelLabel = 'Events';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return StatistikoEventsForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return StatistikoEventsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListStatistikoEvents::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
-154
@@ -1,154 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoEvents\Tables;
|
||||
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\Sport;
|
||||
use App\Models\StatistikoEvent;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
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 StatistikoEventsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->poll('15s')
|
||||
->striped()
|
||||
->columns([
|
||||
IconColumn::make('sport_id')
|
||||
->sortable()
|
||||
->label('')
|
||||
->icon(fn(string $state): string => match ($state) {
|
||||
'1' => 'icon-soccerball',
|
||||
}),
|
||||
TextColumn::make('match_id')->color('info')->icon('phosphor-copy')->copyable()
|
||||
->sortable()
|
||||
->searchable(
|
||||
query: fn($query, $search) => $query->orWhere('match_id', (int) $search)
|
||||
),
|
||||
IconColumn::make('league.sofascore_category.flag')
|
||||
->label('')
|
||||
->icon(function ($state): string {
|
||||
return $state;
|
||||
}),
|
||||
TextColumn::make('league.name')
|
||||
->tooltip(fn($record) => $record->league_id)
|
||||
->sortable(
|
||||
query: fn(Builder $query) => $query->orderBy('name')
|
||||
)
|
||||
->searchable(),
|
||||
TextColumn::make('home.ss_team_name')->color('info')
|
||||
->tooltip(fn($record) => $record->home_id)
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('away.ss_team_name')->color('success')
|
||||
->tooltip(fn($record) => $record->away_id)
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('starttime')->dateTime('Y-m-d H:i')
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('event_filters')
|
||||
->columns(5)->columnSpan(5)
|
||||
->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(function (Get $get) {
|
||||
if ($get('sport_id')) {
|
||||
$leagues = StatistikoEvent::where('sport_id', $get('sport_id'))->groupBy('league_id')->pluck('league_id')->toArray();
|
||||
if ($leagues)
|
||||
return CompetitionGroup::query()->whereIn('id', $leagues)->orderBy('name')->pluck('name', 'id');
|
||||
}
|
||||
})
|
||||
->preload()
|
||||
->searchable()
|
||||
->label('League'),
|
||||
Select::make('home_id')
|
||||
->relationship('home', 'name')
|
||||
->searchable()
|
||||
->label('Home'),
|
||||
Select::make('away_id')
|
||||
->relationship('away', 'name')
|
||||
->searchable()
|
||||
->label('Away'),
|
||||
Checkbox::make('find_double'),
|
||||
])->query(function (Builder $query, array $data): Builder {
|
||||
return $query->when(
|
||||
$data['find_double'],
|
||||
function (Builder $query) use ($data) {
|
||||
if (!$data['sport_id']) {
|
||||
$data['sport_id'] = 1;
|
||||
}
|
||||
StatistikoEvent::where('exp_home', 0)->delete();
|
||||
StatistikoEvent::where('exp_away', 0)->delete();
|
||||
StatistikoEvent::where('exp_handicap', 0)->delete();
|
||||
StatistikoEvent::where('exp_total', 0)->delete();
|
||||
|
||||
$events = StatistikoEvent::where('sport_id', (int) $data['sport_id'])->pluck('match_id')->toArray();
|
||||
$doublEvents = array_diff_assoc(
|
||||
$events,
|
||||
array_unique($events)
|
||||
);
|
||||
$query->whereIn('match_id', $doublEvents)->orderBy('match_id');
|
||||
}
|
||||
)->when(
|
||||
$data['sport_id'],
|
||||
function (Builder $query, $sport_id) {
|
||||
$query->where('sport_id', (int) $sport_id);
|
||||
}
|
||||
)->when(
|
||||
$data['league_id'],
|
||||
function (Builder $query, $league_id) {
|
||||
$query->where('league_id', (int) $league_id);
|
||||
}
|
||||
)->when(
|
||||
$data['home_id'],
|
||||
function (Builder $query, $home_id) {
|
||||
$query->where('home_id', (int) $home_id);
|
||||
}
|
||||
)->when(
|
||||
$data['away_id'],
|
||||
function (Builder $query, $away_id) {
|
||||
$query->where('away_id', (int) $away_id);
|
||||
}
|
||||
);
|
||||
})->indicateUsing(function (array $data): ?string {
|
||||
if (! $data['find_double']) {
|
||||
return null;
|
||||
}
|
||||
return 'Find Double';
|
||||
}),
|
||||
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->filtersFormColumns(5)
|
||||
->persistFiltersInSession()
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton(),
|
||||
DeleteAction::make()->iconButton(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user