wip
This commit is contained in:
1 parent
e09e42ab41
commit
fc1e1b2832
6 files changed
+200
-115
No files matched your search
@@ -11,6 +11,9 @@ use App\Models\SofaScoreRosa;
|
|||||||
use App\Models\SsLineupMemory;
|
use App\Models\SsLineupMemory;
|
||||||
use App\Models\StatisticFixtures;
|
use App\Models\StatisticFixtures;
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Forms\Components\DatePicker;
|
||||||
|
use Filament\Forms\Components\Radio;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Concerns\InteractsWithForms;
|
use Filament\Forms\Concerns\InteractsWithForms;
|
||||||
use Filament\Forms\Contracts\HasForms;
|
use Filament\Forms\Contracts\HasForms;
|
||||||
@@ -82,104 +85,14 @@ class PlayerProps extends Page implements HasForms
|
|||||||
return $schema
|
return $schema
|
||||||
->columns(5)
|
->columns(5)
|
||||||
->components([
|
->components([
|
||||||
Select::make('cid')
|
$this->selectCountry(),
|
||||||
->live()
|
$this->selectLeague(),
|
||||||
->preload()
|
$this->selectMatch(),
|
||||||
->searchable(false)
|
$this->selectTeam(),
|
||||||
->prefixIconColor(fn (Get $get): string => $get('cid') ? 'success' : 'danger')
|
$this->selectLineup(),
|
||||||
->prefixIcon('phosphor-globe-fill')
|
// $this->radioSeasonOrDate(),
|
||||||
->hiddenLabel()
|
// $this->datePickerStartDate(),
|
||||||
->options(fn () => LoadSofaScoreCategory::load())
|
// $this->datePickerEndDate(),
|
||||||
->placeholder('Country')
|
|
||||||
->afterStateUpdated(function (callable $set, $state) {
|
|
||||||
$set('lid', null);
|
|
||||||
$set('mid', null);
|
|
||||||
$set('tid', null);
|
|
||||||
$this->dispatch('clear-all');
|
|
||||||
}),
|
|
||||||
Select::make('lid')
|
|
||||||
->live()
|
|
||||||
->preload()
|
|
||||||
->prefixIconColor(fn (Get $get): string => $get('lid') ? 'success' : 'danger')
|
|
||||||
->prefixIcon('phosphor-trophy-fill')
|
|
||||||
->hiddenLabel()
|
|
||||||
->options(fn (Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('cid')))
|
|
||||||
->placeholder('League')
|
|
||||||
->afterStateUpdated(function (callable $set) {
|
|
||||||
$set('mid', null);
|
|
||||||
$set('tid', null);
|
|
||||||
$this->dispatch('clear-all');
|
|
||||||
}),
|
|
||||||
Select::make('mid')
|
|
||||||
->live()
|
|
||||||
->hiddenLabel()
|
|
||||||
->prefixIconColor(fn (Get $get): string => $get('mid') ? 'success' : 'danger')
|
|
||||||
->prefixIcon('phosphor-calendar-check-fill')
|
|
||||||
->options(function (Get $get) {
|
|
||||||
return LoadStatisticFixturesMatchOptions::load($get('lid'));
|
|
||||||
})
|
|
||||||
->afterStateUpdated(function (callable $set, $state) {
|
|
||||||
$set('tid', null);
|
|
||||||
if ($state) {
|
|
||||||
$this->dispatch('match-update', match_id: $state);
|
|
||||||
} else {
|
|
||||||
$this->dispatch('clear-all');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->placeholder('Events'),
|
|
||||||
|
|
||||||
Select::make('tid')
|
|
||||||
->live()
|
|
||||||
->hiddenLabel()
|
|
||||||
->prefixIconColor(fn (Get $get): string => $get('tid') ? 'success' : 'danger')
|
|
||||||
->prefixIcon('icon-player')
|
|
||||||
->options(function (Get $get) {
|
|
||||||
if ($get('mid')) {
|
|
||||||
$res = StatisticFixtures::where('id', $get('mid'))->first();
|
|
||||||
|
|
||||||
$arr = [];
|
|
||||||
if ($res) {
|
|
||||||
$arr[$res->home_id] = SofaScoreRosa::query()->where('ss_team_id', $res->home_id)->value('ss_team_name');
|
|
||||||
$arr[$res->away_id] = SofaScoreRosa::query()->where('ss_team_id', $res->away_id)->value('ss_team_name');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $arr;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->placeholder('Team')
|
|
||||||
->afterStateUpdated(function ($state, Set $set) {
|
|
||||||
if ($state) {
|
|
||||||
$this->dispatch('team-update', team_id: $state);
|
|
||||||
$tmp = SsLineupMemory::where('client_id', Auth::user()->client_id)->where('team_id', $state)->orderBy('created_at', 'desc')->first();
|
|
||||||
if ($tmp) {
|
|
||||||
$set('lineup', $tmp->lineup);
|
|
||||||
$this->dispatch('lineup-update', activeLineUp: $tmp->lineup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
Select::make('lineup')
|
|
||||||
->live()
|
|
||||||
->hiddenLabel()
|
|
||||||
->allowHtml()
|
|
||||||
->native(false)
|
|
||||||
->selectablePlaceholder(false)
|
|
||||||
->prefixIconColor('info')
|
|
||||||
->prefixIcon('icon-soccerfield-fill')
|
|
||||||
->options(function () {
|
|
||||||
$res = $this->lineUpOptions();
|
|
||||||
$arr = [];
|
|
||||||
foreach ($res as $key => $value) {
|
|
||||||
$arr[$key] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $arr;
|
|
||||||
})
|
|
||||||
->placeholder('LineUp')
|
|
||||||
->searchable()
|
|
||||||
->default($this->activeLineUp)
|
|
||||||
->afterStateUpdated(function ($state) {
|
|
||||||
$this->dispatch('lineup-update', activeLineUp: $state);
|
|
||||||
}),
|
|
||||||
])->statePath('filterData');
|
])->statePath('filterData');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,4 +187,174 @@ class PlayerProps extends Page implements HasForms
|
|||||||
'541+' => '541+',
|
'541+' => '541+',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function selectTeam(): Select
|
||||||
|
{
|
||||||
|
return Select::make('tid')
|
||||||
|
->live()
|
||||||
|
->hiddenLabel()
|
||||||
|
->prefixIconColor(fn (Get $get): string => $get('tid') ? 'success' : 'danger')
|
||||||
|
->prefixIcon('icon-player')
|
||||||
|
->options(function (Get $get) {
|
||||||
|
if ($get('mid')) {
|
||||||
|
$res = StatisticFixtures::where('id', $get('mid'))->first();
|
||||||
|
|
||||||
|
$arr = [];
|
||||||
|
if ($res) {
|
||||||
|
$arr[$res->home_id] = SofaScoreRosa::query()->where('ss_team_id', $res->home_id)->value('ss_team_name');
|
||||||
|
$arr[$res->away_id] = SofaScoreRosa::query()->where('ss_team_id', $res->away_id)->value('ss_team_name');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->placeholder('Team')
|
||||||
|
->afterStateUpdated(function ($state, Set $set) {
|
||||||
|
if ($state) {
|
||||||
|
$this->dispatch('team-update', team_id: $state);
|
||||||
|
$tmp = SsLineupMemory::where('client_id', Auth::user()->client_id)->where('team_id', $state)->orderBy('created_at', 'desc')->first();
|
||||||
|
if ($tmp) {
|
||||||
|
$set('lineup', $tmp->lineup);
|
||||||
|
$this->dispatch('lineup-update', activeLineUp: $tmp->lineup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function selectLeague(): Select
|
||||||
|
{
|
||||||
|
return Select::make('lid')
|
||||||
|
->live()
|
||||||
|
->preload()
|
||||||
|
->prefixIconColor(fn (Get $get): string => $get('lid') ? 'success' : 'danger')
|
||||||
|
->prefixIcon('phosphor-trophy-fill')
|
||||||
|
->hiddenLabel()
|
||||||
|
->options(fn (Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('cid')))
|
||||||
|
->placeholder('League')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('mid', null);
|
||||||
|
$set('tid', null);
|
||||||
|
$this->dispatch('clear-all');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function selectMatch(): Select
|
||||||
|
{
|
||||||
|
return Select::make('mid')
|
||||||
|
->live()
|
||||||
|
->hiddenLabel()
|
||||||
|
->prefixIconColor(fn (Get $get): string => $get('mid') ? 'success' : 'danger')
|
||||||
|
->prefixIcon('phosphor-calendar-check-fill')
|
||||||
|
->options(function (Get $get) {
|
||||||
|
return LoadStatisticFixturesMatchOptions::load($get('lid'));
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function (callable $set, $state) {
|
||||||
|
$set('tid', null);
|
||||||
|
if ($state) {
|
||||||
|
$this->dispatch('match-update', match_id: $state);
|
||||||
|
} else {
|
||||||
|
$this->dispatch('clear-all');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->placeholder('Events');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function selectLineup(): Select
|
||||||
|
{
|
||||||
|
return Select::make('lineup')
|
||||||
|
->live()
|
||||||
|
->hiddenLabel()
|
||||||
|
->allowHtml()
|
||||||
|
->native(false)
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->prefixIconColor('info')
|
||||||
|
->prefixIcon('icon-soccerfield-fill')
|
||||||
|
->options(function () {
|
||||||
|
$res = $this->lineUpOptions();
|
||||||
|
$arr = [];
|
||||||
|
foreach ($res as $key => $value) {
|
||||||
|
$arr[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arr;
|
||||||
|
})
|
||||||
|
->placeholder('LineUp')
|
||||||
|
->searchable()
|
||||||
|
->default($this->activeLineUp)
|
||||||
|
->afterStateUpdated(function ($state) {
|
||||||
|
$this->dispatch('lineup-update', activeLineUp: $state);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function selectCountry(): Select
|
||||||
|
{
|
||||||
|
return Select::make('cid')
|
||||||
|
->live()
|
||||||
|
->preload()
|
||||||
|
->searchable(false)
|
||||||
|
->prefixIconColor(fn (Get $get): string => $get('cid') ? 'success' : 'danger')
|
||||||
|
->prefixIcon('phosphor-globe-fill')
|
||||||
|
->hiddenLabel()
|
||||||
|
->options(fn () => LoadSofaScoreCategory::load())
|
||||||
|
->placeholder('Country')
|
||||||
|
->afterStateUpdated(function (callable $set, $state) {
|
||||||
|
$set('lid', null);
|
||||||
|
$set('mid', null);
|
||||||
|
$set('tid', null);
|
||||||
|
$this->dispatch('clear-all');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function radioSeasonOrDate(): Radio
|
||||||
|
{
|
||||||
|
return Radio::make('season_or_date')
|
||||||
|
->live()
|
||||||
|
->extraAttributes([
|
||||||
|
'class' => 'radio-statistic-group',
|
||||||
|
])
|
||||||
|
->columnSpan(2)
|
||||||
|
->inline()
|
||||||
|
->default('season')
|
||||||
|
->hiddenLabel()
|
||||||
|
->options([
|
||||||
|
'season' => 'Season',
|
||||||
|
'date' => 'Date',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function datePickerStartDate(): DatePicker
|
||||||
|
{
|
||||||
|
return DatePicker::make('start_date')
|
||||||
|
->live()
|
||||||
|
->hiddenLabel()
|
||||||
|
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
|
||||||
|
->native(false)
|
||||||
|
->prefixIconColor(fn (Get $get): string => $get('start_date') ? 'success' : 'primary')
|
||||||
|
->prefixIcon('phosphor-calendar')
|
||||||
|
->prefix('Start')
|
||||||
|
->suffixAction(
|
||||||
|
Action::make('clear_start')
|
||||||
|
->icon('phosphor-x')
|
||||||
|
->color('gray')
|
||||||
|
->action(fn (Set $set) => $set('start_date', null))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function datePickerEndDate(): DatePicker
|
||||||
|
{
|
||||||
|
return DatePicker::make('end_date')
|
||||||
|
->live()
|
||||||
|
->hiddenLabel()
|
||||||
|
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
|
||||||
|
->native(false)
|
||||||
|
->prefixIconColor(fn (Get $get): string => $get('end_date') ? 'success' : 'primary')
|
||||||
|
->prefixIcon('phosphor-calendar')
|
||||||
|
->prefix('End')
|
||||||
|
->suffixAction(
|
||||||
|
Action::make('clear_end')
|
||||||
|
->icon('phosphor-x')
|
||||||
|
->color('gray')
|
||||||
|
->action(fn (Set $set) => $set('end_date', null))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ use App\Models\StatistikoEvent;
|
|||||||
|
|
||||||
class LoadPlayerSelection
|
class LoadPlayerSelection
|
||||||
{
|
{
|
||||||
public static function load(?int $team_id, ?string $team_position, ?int $sofascore_category_id, ?array $season, ?string $seasonmode)
|
public static function load(?int $team_id, ?string $team_position, ?array $season, ?string $seasonmode)
|
||||||
{
|
{
|
||||||
$season = GetSeason::load($season, $seasonmode);
|
$season = GetSeason::load($season, $seasonmode);
|
||||||
$matches = StatistikoEvent::whereIn('season', $season)
|
$matches = StatistikoEvent::whereIn('season', $season)
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ use Illuminate\Support\Carbon;
|
|||||||
|
|
||||||
class LoadSeasons
|
class LoadSeasons
|
||||||
{
|
{
|
||||||
public static function load($seasonmode)
|
public static function load(string $seasonmode)
|
||||||
{
|
{
|
||||||
if (!$seasonmode) {
|
if (! $seasonmode) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,13 +17,14 @@ class LoadSeasons
|
|||||||
$period = CarbonPeriod::create(Carbon::now()->year(2024), '1 year', Carbon::now());
|
$period = CarbonPeriod::create(Carbon::now()->year(2024), '1 year', Carbon::now());
|
||||||
foreach ($period as $date) {
|
foreach ($period as $date) {
|
||||||
if ($seasonmode == 'halfyear') {
|
if ($seasonmode == 'halfyear') {
|
||||||
if ((int) date('m') > 7)
|
if ((int) date('m') > 7) {
|
||||||
$tmp = $date->format('y') . '/' . $date->format('y') + 1;
|
$tmp = $date->format('y').'/'.$date->format('y') + 1;
|
||||||
else
|
} else {
|
||||||
$tmp = $date->format('y') - 1 . '/' . $date->format('y');
|
$tmp = $date->format('y') - 1 .'/'.$date->format('y');
|
||||||
|
}
|
||||||
$season[$tmp] = $tmp;
|
$season[$tmp] = $tmp;
|
||||||
} else {
|
} else {
|
||||||
$season[(string) $date->year] = (string) $date->year;
|
$season[(string) $date->year] = (string) $date->year;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -576,11 +576,10 @@ class Statistic extends BaseDashboard
|
|||||||
->options(function (Get $get) {
|
->options(function (Get $get) {
|
||||||
$team_id = $get('team_id');
|
$team_id = $get('team_id');
|
||||||
$team_position = $get('team_position');
|
$team_position = $get('team_position');
|
||||||
$sofascore_category_id = $get('sofascore_category_id');
|
|
||||||
$season = $get('season');
|
$season = $get('season');
|
||||||
$seasonmode = $get('seasonmode');
|
$seasonmode = $get('seasonmode');
|
||||||
|
|
||||||
return LoadPlayerSelection::load($team_id, $team_position, $sofascore_category_id, $season, $seasonmode);
|
return LoadPlayerSelection::load($team_id, $team_position, $season, $seasonmode);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,7 +634,6 @@ class Statistic extends BaseDashboard
|
|||||||
->hidden(fn (Get $get) => $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
|
->hidden(fn (Get $get) => $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
|
||||||
->prefixIcon('phosphor-calendar-star')
|
->prefixIcon('phosphor-calendar-star')
|
||||||
->options(function (Get $get) {
|
->options(function (Get $get) {
|
||||||
// dd($get('seasonmode'));
|
|
||||||
if ($get('seasonmode') == 'halfyear') {
|
if ($get('seasonmode') == 'halfyear') {
|
||||||
return ['26/27' => '26/27', '25/26' => '25/26', '24/25' => '24/25'];
|
return ['26/27' => '26/27', '25/26' => '25/26', '24/25' => '24/25'];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ class Expectation1X2
|
|||||||
public static function load(array &$expectations, array $filter, object $match)
|
public static function load(array &$expectations, array $filter, object $match)
|
||||||
{
|
{
|
||||||
$team_id = (int) $filter['team_id'] ?? 0;
|
$team_id = (int) $filter['team_id'] ?? 0;
|
||||||
$team_position = $filter['team_position'];
|
$home_id = $match->home_id;
|
||||||
|
$away_id = $match->away_id;
|
||||||
|
|
||||||
$res_tp = LoadEventsQueryTP::load($filter, $match);
|
$res_tp = LoadEventsQueryTP::load($filter, $match);
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ class Expectation1X2
|
|||||||
|
|
||||||
$expectations += ['win_count' => 0, 'draw_count' => 0, 'lost_count' => 0];
|
$expectations += ['win_count' => 0, 'draw_count' => 0, 'lost_count' => 0];
|
||||||
foreach ($res_tp as $value) {
|
foreach ($res_tp as $value) {
|
||||||
if ($team_id && $team_position == 'home') {
|
if ($value->home_id == $team_id) {
|
||||||
switch ($value['result_code']) {
|
switch ($value['result_code']) {
|
||||||
case '1':
|
case '1':
|
||||||
$expectations['win_count']++;
|
$expectations['win_count']++;
|
||||||
@@ -31,15 +32,15 @@ class Expectation1X2
|
|||||||
$expectations['lost_count']++;
|
$expectations['lost_count']++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} elseif ($team_id && $team_position == 'away') {
|
} elseif ($value->away_id == $team_id) {
|
||||||
switch ($value['result_code']) {
|
switch ($value['result_code']) {
|
||||||
case '1':
|
case '2':
|
||||||
$expectations['win_count']++;
|
$expectations['win_count']++;
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
$expectations['draw_count']++;
|
$expectations['draw_count']++;
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '1':
|
||||||
$expectations['lost_count']++;
|
$expectations['lost_count']++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,8 +106,11 @@ class PlayerPropsDrop extends Widget
|
|||||||
public function syncData(?int $team_id)
|
public function syncData(?int $team_id)
|
||||||
{
|
{
|
||||||
if ($team_id) {
|
if ($team_id) {
|
||||||
|
|
||||||
$this->players = PlayerCalculator::load($team_id);
|
$this->players = PlayerCalculator::load($team_id);
|
||||||
|
|
||||||
$this->team_name = SofaScoreRosa::where('ss_team_id', $team_id)->value('ss_team_name');
|
$this->team_name = SofaScoreRosa::where('ss_team_id', $team_id)->value('ss_team_name');
|
||||||
|
|
||||||
$this->team_id = $team_id;
|
$this->team_id = $team_id;
|
||||||
$this->loadPlacement();
|
$this->loadPlacement();
|
||||||
} else {
|
} else {
|
||||||
@@ -176,7 +179,6 @@ class PlayerPropsDrop extends Widget
|
|||||||
$res = SsLineupMemory::where('client_id', Auth::user()->client_id)->where('team_id', $this->team_id)->where('lineup', $this->activeLineUp)->first();
|
$res = SsLineupMemory::where('client_id', Auth::user()->client_id)->where('team_id', $this->team_id)->where('lineup', $this->activeLineUp)->first();
|
||||||
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
// Log::debug('SsLineupMemory', $res->toArray());
|
|
||||||
|
|
||||||
$placement = json_decode($res->placement, 1);
|
$placement = json_decode($res->placement, 1);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user