128 lines
5.4 KiB
PHP
128 lines
5.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use App\Models\CompetitionGroup;
|
|
use App\Models\Element;
|
|
use App\Models\StatisticFixtures;
|
|
use BackedEnum;
|
|
use Filament\Forms\Components\DatePicker;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\Slider;
|
|
use Filament\Pages\Dashboard as BaseDashboard;
|
|
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Components\Utilities\Get;
|
|
use Filament\Schemas\Schema;
|
|
|
|
class Statistic extends BaseDashboard
|
|
{
|
|
use HasFiltersForm;
|
|
|
|
protected static string|BackedEnum|null $navigationIcon = 'phosphor-chart-line-up';
|
|
|
|
protected static ?string $title = 'Statistic';
|
|
|
|
protected int|string|array $columnSpan = 'full';
|
|
|
|
public function filtersForm(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Section::make()
|
|
->schema([
|
|
Select::make('league_id')
|
|
->prefixIcon('phosphor-trophy')
|
|
->options(function () {
|
|
$res = StatisticFixtures::where('sport_id', 1)
|
|
->groupBy('league_id')
|
|
->pluck('league_id')->toArray();
|
|
|
|
return CompetitionGroup::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
|
})
|
|
->preload()
|
|
->searchable()
|
|
->live()
|
|
->label('League'),
|
|
Select::make('team_id')
|
|
->prefixIcon('icon-team')
|
|
->options(function (Get $get) {
|
|
if ($get('league_id')) {
|
|
$res = StatisticFixtures::where('league_id', $get('league_id'))->get();
|
|
$arr = [];
|
|
foreach ($res as $value) {
|
|
$arr[] = $value->home_id;
|
|
$arr[] = $value->away_id;
|
|
}
|
|
|
|
$arr = array_unique($arr);
|
|
|
|
return Element::query()->whereIn('id', $arr)->orderBy('name')->pluck('name', 'id');
|
|
}
|
|
})
|
|
->preload()
|
|
->searchable()
|
|
->label('Team'),
|
|
DatePicker::make('startDate'),
|
|
DatePicker::make('endDate'),
|
|
])->columns(4)
|
|
->columnSpanFull(),
|
|
Section::make()
|
|
->schema([
|
|
Select::make('palyer_id')
|
|
->label('Player')
|
|
->prefixIcon('icon-player')
|
|
->options(function () {
|
|
$res = StatisticFixtures::where('sport_id', 1)
|
|
->groupBy('league_id')
|
|
->pluck('league_id')->toArray();
|
|
|
|
return CompetitionGroup::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
|
})
|
|
->preload()
|
|
->searchable()
|
|
->live(),
|
|
Select::make('team_position')
|
|
->prefixIcon('phosphor-map-pin')
|
|
->default('home')
|
|
->selectablePlaceholder(false)
|
|
->options([
|
|
'home' => 'Home',
|
|
'away' => 'Away',
|
|
'all' => 'All',
|
|
]),
|
|
Select::make('similar_past_matches')
|
|
->prefixIcon('phosphor-align-center-horizontal')
|
|
->default('none')
|
|
->selectablePlaceholder(false)
|
|
->options([
|
|
'none' => 'None',
|
|
'league' => 'League',
|
|
'all' => 'All Database',
|
|
]),
|
|
Select::make('statistic_type')
|
|
->prefixIcon('phosphor-cell-signal-full')
|
|
->default('none')
|
|
->selectablePlaceholder(false)
|
|
->options([
|
|
'gls' => 'Gouls',
|
|
'crn' => 'Corner',
|
|
'fls' => 'Fouls commited',
|
|
'ofs' => 'Offside',
|
|
'crd' => 'Cards',
|
|
'snt' => 'Shot on target',
|
|
'tsh' => 'Total shots',
|
|
]),
|
|
])->columns(4)
|
|
->columnSpanFull(),
|
|
Slider::make('accuracy')
|
|
->default(0.5)
|
|
->decimalPlaces(1)
|
|
->tooltips()
|
|
->fillTrack()
|
|
->range(minValue: 0, maxValue: 1)
|
|
->pips(),
|
|
]);
|
|
}
|
|
}
|