153 lines
6.3 KiB
PHP
153 lines
6.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use App\Actions\LoadStatisticFixturesLeaguesOptions;
|
|
use App\Filament\Widgets\MovingAverageChart;
|
|
use App\Filament\Widgets\PunctualChart;
|
|
use App\Models\Element;
|
|
use App\Models\StatisticFixtures;
|
|
use BackedEnum;
|
|
use Filament\Actions\Action;
|
|
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';
|
|
|
|
public function filtersForm(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Section::make()
|
|
->schema([
|
|
Select::make('league_id')
|
|
->prefixIcon('phosphor-trophy')
|
|
->options(fn () => LoadStatisticFixturesLeaguesOptions::load(1))
|
|
->preload()
|
|
->searchable()
|
|
->live()
|
|
->label('League')
|
|
->afterStateUpdated(function (callable $set) {
|
|
$set('team_id', null);
|
|
}),
|
|
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([
|
|
'draft' => 'Sep Maier',
|
|
])
|
|
->preload()
|
|
->searchable()
|
|
->live(),
|
|
Select::make('team_position')
|
|
->prefixIcon('phosphor-map-pin')
|
|
->suffixAction(
|
|
Action::make('iconInfo')
|
|
->color('gray')
|
|
->icon('phosphor-question')
|
|
->tooltip('Lorem ipsum dolor sit amet, consetetur sadipscing elitr.')
|
|
)
|
|
->default('all')
|
|
->selectablePlaceholder(false)
|
|
->options([
|
|
'all' => 'All',
|
|
'home' => 'Home',
|
|
'away' => 'Away',
|
|
]),
|
|
Select::make('similar_past_matches')
|
|
->prefixIcon('phosphor-align-center-horizontal')
|
|
->suffixAction(
|
|
Action::make('iconInfo')
|
|
->color('gray')
|
|
->icon('phosphor-question')
|
|
->tooltip('Lorem ipsum dolor sit amet, consetetur sadipscing elitr.')
|
|
)
|
|
->default('none')
|
|
->selectablePlaceholder(false)
|
|
->options([
|
|
'none' => 'None',
|
|
'league' => 'League',
|
|
'all' => 'All Database',
|
|
]),
|
|
Select::make('statistic_type')
|
|
->prefixIcon('phosphor-cell-signal-full')
|
|
->suffixAction(
|
|
Action::make('iconInfo')
|
|
->color('gray')
|
|
->icon('phosphor-question')
|
|
->tooltip('Lorem ipsum dolor sit amet, consetetur sadipscing elitr.')
|
|
)
|
|
->default('none')
|
|
->selectablePlaceholder(false)
|
|
->options([
|
|
'gls' => 'Goals',
|
|
'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(),
|
|
]);
|
|
}
|
|
|
|
public function update()
|
|
{
|
|
dd($this->filter);
|
|
}
|
|
|
|
protected function getFooterWidgets(): array
|
|
{
|
|
return [
|
|
PunctualChart::make(),
|
|
MovingAverageChart::make(),
|
|
];
|
|
}
|
|
}
|