2,
'xl' => 3,
];
public function getActiveTab()
{
return $this->activeTab;
}
public function getHeading(): string|Htmlable|null
{
return '';
}
public function filtersForm(Schema $schema): Schema
{
return $schema
->components([
Grid::make([
'default' => 1,
'sm' => 3,
'md' => 4,
])
->columnSpanFull()
->schema([
Select::make('league_id')
// ->prefixIconColor('primary')
->prefixIconColor(fn(Get $get): string => $get('league_id') ? 'success' : 'danger')
->prefixIcon('phosphor-trophy')
->hiddenLabel()
->options(fn() => LoadStatisticFixturesLeaguesOptions::load(1))
->live()
->placeholder('League')
->afterStateUpdated(function (callable $set, $state) {
$set('match_id', null);
$set('team_id', null);
$set('tm_player_id', null);
$set('season', null);
}),
Select::make('match_id')
->hiddenLabel()
->prefixIconColor(fn(Get $get): string => $get('match_id') ? 'success' : 'danger')
->prefixIcon('phosphor-calendar-check')
->options(function (Get $get) {
return LoadStatisticFixturesMatchOptions::load($get('league_id'));
})
->afterStateUpdated(function (callable $set) {
$set('team_id', null);
$set('tm_player_id', null);
})
->live()
->placeholder('Events'),
Select::make('team_id')
->hiddenLabel()
->prefixIconColor(function (Get $get): string {
if ($get('team_id')) {
return 'success';
} elseif ($get('similar_past_matches') != 'none') {
return 'gray';
} else {
return 'danger';
}
})
->prefixIcon('phosphor-users-three')
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
->options(function (Get $get) {
if ($get('match_id')) {
$res = StatisticFixtures::where('id', $get('match_id'))->first();
$arr = [];
$arr[$res->home_id] = Element::query()->where('id', $res->home_id)->value('name');
$arr[$res->away_id] = Element::query()->where('id', $res->away_id)->value('name');
return $arr;
}
})
->afterStateUpdated(function (callable $set) {
$set('tm_player_id', null);
})
->live()
->placeholder('Team'),
Select::make('team_position')
->hiddenLabel()
->placeholder('Team Position')
->prefix('TP')
->prefixAction(
Action::make('iconInfo')
->icon('phosphor-question')
->tooltip(fn() => 'Team Position')
)
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
->default('all')
->selectablePlaceholder(false)
->options([
'all' => 'All',
'home' => 'Home',
'away' => 'Away',
])
->live(),
]),
Grid::make([
'default' => 1,
'sm' => 3,
'md' => 4,
])
->columnSpanFull()
->schema([
Select::make('similar_past_matches')
->hiddenLabel()
->placeholder('Similar Past Matches')
->prefixIconColor('primary')
->suffix(fn(Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('
± ' . $get('accuracy') . '
') : '')
->prefixAction(
Action::make('iconInfo')
->icon('phosphor-question')
->tooltip(fn() => $this->tooltip_similar_past_matches())
)
->default('none')
->live()
->selectablePlaceholder(false)
->afterStateUpdated(function (callable $set) {
$set('team_id', null);
$set('tm_player_id', null);
$set('team_position', null);
})
->options([
'none' => 'SPM: None',
'league' => 'SPM: League',
'all' => 'SPM: All Database',
]),
Slider::make('accuracy')
// ->label('Accuracy min: 0, max: 0.25, steps: 0.025')
->hiddenLabel()
->hidden(fn(Get $get) => $get('similar_past_matches') == 'none')
->fillTrack()
->minValue(0)
->maxValue(0.25)
->default(0.125)
->step(0.025)
->decimalPlaces(3)
// ->tooltips()
// ->columnSpan([
// 'default' => 1,
// 'xl' => 2,
// ])
->pips()
->pipsFormatter(RawJs::make(<<<'JS'
`${$value.toFixed(2)}`
JS))
->live(),
Select::make('tm_player_id')
->hiddenLabel()
->allowHtml()
->placeholder('Player')
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
->prefixIconColor(fn(Get $get): string => $get('similar_past_matches') == 'none' ? 'primary' : '')
->prefixIcon('icon-player')
->suffixAction(
Action::make('copyCostToPrice')
->action(function (callable $set) {
$set('tm_player_id', null);
$set('player_on_field', null);
})
->color('gray')
->icon('phosphor-x'),
)
->preload()
->options(function (Get $get) {
return LoadPlayer::load($get('team_id'));
})
->live(),
Select::make('player_on_field')
->hiddenLabel()
->placeholder('Time on field')
->prefixIcon('phosphor-watch')
->default('all')
->hidden(fn(Get $get) => ! $get('tm_player_id') or $get('similar_past_matches') != 'none')
->prefixIconColor(fn(Get $get): string => ($get('tm_player_id') and $get('similar_past_matches') == 'none') ? 'primary' : '')
->selectablePlaceholder(false)
->options([
'all' => 'All',
'lineup' => 'Lineup',
'substituted' => 'Substituted',
'notplayed' => 'Not Played',
])
->live(),
]),
Grid::make([
'default' => 4,
'sm' => 4,
])
->schema([
Radio::make('season_or_date')
->extraAttributes([
'class' => 'radio-statistic-group',
])
->columnSpan([
'default' => 4,
'sm' => 4,
])
->inline()
->live()
->default('season')
->hiddenLabel()
->options([
'season' => 'Season',
'date' => 'Date',
]),
]),
Select::make('season')
->columns(2)
->hiddenLabel()
->multiple()
->placeholder('Season')
->hidden(fn(Get $get) => $get('season_or_date') == 'date')
->prefixIcon('phosphor-calendar-star')
->prefixIconColor('primary')
->preload()
->options(function (Get $get) {
return LoadSeasons::load($get('league_id'));
})
->afterStateUpdated(function (callable $set) {
$set('team_id', null);
$set('tm_player_id', null);
})
->live(),
DatePicker::make('start_date')
->hiddenLabel()
->hidden(fn(Get $get) => $get('season_or_date') == 'season')
->native(false)
->prefixIconColor('primary')
->prefixIcon('phosphor-calendar')
->live()
->prefix('Start')
->suffixAction(
Action::make('clear_start')
->icon('phosphor-x')
->color('gray')
->action(fn(Set $set) => $set('start_date', null))
),
DatePicker::make('end_date')
->hiddenLabel()
->hidden(fn(Get $get) => $get('season_or_date') == 'season')
->native(false)
->prefixIconColor('primary')
->prefixIcon('phosphor-calendar')
->live()
->prefix('End')
->suffixAction(
Action::make('clear_end')
->icon('phosphor-x')
->color('gray')
->action(fn(Set $set) => $set('end_date', null))
),
]);
}
protected function tooltip_similar_past_matches(): HtmlString
{
$str = '';
$str .= '
Similar Past Matches (SMP)
';
$str .= '
None
';
$str .= '
Team within selected league
';
$str .= '
League
';
$str .= '
Simmilar events in league in the range of slider.
';
$str .= '
All Database
';
$str .= '
Simmilar events in database in the range of slider.
';
$str .= '
';
return new HtmlString($str);
}
}