fix season
This commit is contained in:
1 parent
d220e340e2
commit
7e30e93f90
5 files changed
+56
-48
No files matched your search
@@ -2,24 +2,25 @@
|
|||||||
|
|
||||||
namespace App\Filament\Pages\Selections\Helper;
|
namespace App\Filament\Pages\Selections\Helper;
|
||||||
|
|
||||||
use App\Models\SofaScoreCategory;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
class GetSeason
|
class GetSeason
|
||||||
{
|
{
|
||||||
public static function load(array $season, int|null $sofascore_category_id)
|
public static function load(array|null $season, string|null $seasonmode)
|
||||||
{
|
{
|
||||||
if (!is_array($season) || !count($season)) {
|
if (!\is_array($season) || !\count($season)) {
|
||||||
if ($sofascore_category_id) {
|
|
||||||
$season_mode = SofaScoreCategory::where('id', $sofascore_category_id)->value('season_mode');
|
$date = Carbon::now();
|
||||||
if ($season_mode == 'halfyear') {
|
|
||||||
if ((int) date('m') > 7)
|
$season = [];
|
||||||
$season[] = date('y') . '/' . date('y', strtotime('+1 year'));
|
if ($seasonmode == 'halfyear') {
|
||||||
else
|
if ((int) date('m') > 7)
|
||||||
$season[] = date('y', strtotime('-1 year')) . '/' . date('y');
|
$tmp = $date->format('y') . '/' . $date->format('y') + 1;
|
||||||
}
|
else
|
||||||
else {
|
$tmp = $date->format('y') - 1 . '/' . $date->format('y');
|
||||||
$season[] = date('Y');
|
$season[$tmp] = $tmp;
|
||||||
}
|
} else {
|
||||||
|
$season[$date->year] = $date->year;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,30 +2,33 @@
|
|||||||
|
|
||||||
namespace App\Filament\Pages\Selections;
|
namespace App\Filament\Pages\Selections;
|
||||||
|
|
||||||
use App\Models\SofaScoreCategory;
|
use Carbon\CarbonPeriod;
|
||||||
use App\Models\StatistikoEvent;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
class LoadSeasons
|
class LoadSeasons
|
||||||
{
|
{
|
||||||
public static function load($sofascore_category_id)
|
public static function load($seasonmode)
|
||||||
{
|
{
|
||||||
if(!$sofascore_category_id){
|
if (!$seasonmode) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$season_mode = SofaScoreCategory::where('id', $sofascore_category_id)->value('season_mode');
|
|
||||||
|
|
||||||
$arr = [];
|
$season = [];
|
||||||
if($season_mode == 'fullyear') {
|
$period = CarbonPeriod::create(Carbon::now()->year(2024), '1 year', Carbon::now());
|
||||||
$arr[2024] = 2024;
|
foreach ($period as $date) {
|
||||||
$arr[2025] = 2025;
|
if ($seasonmode == 'halfyear') {
|
||||||
$arr[2026] = 2026;
|
if ((int) date('m') > 7)
|
||||||
}else {
|
$tmp = $date->format('y') . '/' . $date->format('y') + 1;
|
||||||
$arr['24/25'] = '24/25';
|
else
|
||||||
$arr['25/26'] = '25/26';
|
$tmp = $date->format('y') - 1 . '/' . $date->format('y');
|
||||||
$arr['26/27'] = '26/27';
|
$season[$tmp] = $tmp;
|
||||||
|
} else {
|
||||||
|
$season[$date->year] = $date->year;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $arr;
|
$season = array_reverse($season);
|
||||||
|
|
||||||
|
return $season;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,12 +7,14 @@ use App\Actions\LoadStatisticFixturesLeaguesOptions;
|
|||||||
use App\Actions\LoadStatisticFixturesMatchOptions;
|
use App\Actions\LoadStatisticFixturesMatchOptions;
|
||||||
use App\Filament\Pages\Selections\LoadPlayer;
|
use App\Filament\Pages\Selections\LoadPlayer;
|
||||||
use App\Filament\Pages\Selections\LoadSeasons;
|
use App\Filament\Pages\Selections\LoadSeasons;
|
||||||
|
use App\Models\SofaScoreCategory;
|
||||||
use App\Models\SofaScoreRosa;
|
use App\Models\SofaScoreRosa;
|
||||||
use App\Models\StatisticFixtures;
|
use App\Models\StatisticFixtures;
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
|
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\DatePicker;
|
use Filament\Forms\Components\DatePicker;
|
||||||
|
use Filament\Forms\Components\Hidden;
|
||||||
use Filament\Forms\Components\Radio;
|
use Filament\Forms\Components\Radio;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\Slider;
|
use Filament\Forms\Components\Slider;
|
||||||
@@ -104,6 +106,7 @@ class Statistic extends BaseDashboard
|
|||||||
])
|
])
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
->schema([
|
->schema([
|
||||||
|
Hidden::make('seasonmode'),
|
||||||
Select::make('sofascore_category_id')
|
Select::make('sofascore_category_id')
|
||||||
->live()
|
->live()
|
||||||
->preload()
|
->preload()
|
||||||
@@ -113,7 +116,8 @@ class Statistic extends BaseDashboard
|
|||||||
->hiddenLabel()
|
->hiddenLabel()
|
||||||
->options(fn() => LoadSofaScoreCategory::load())
|
->options(fn() => LoadSofaScoreCategory::load())
|
||||||
->placeholder('Country')
|
->placeholder('Country')
|
||||||
->afterStateUpdated(function (callable $set) {
|
->afterStateUpdated(function (callable $set, $state) {
|
||||||
|
$set('seasonmode', SofaScoreCategory::where('id', $state)->value('season_mode'));
|
||||||
$set('league_id', null);
|
$set('league_id', null);
|
||||||
$set('match_id', null);
|
$set('match_id', null);
|
||||||
$set('team_id', null);
|
$set('team_id', null);
|
||||||
@@ -133,7 +137,6 @@ class Statistic extends BaseDashboard
|
|||||||
$set('match_id', null);
|
$set('match_id', null);
|
||||||
$set('team_id', null);
|
$set('team_id', null);
|
||||||
$set('ss_player_id', null);
|
$set('ss_player_id', null);
|
||||||
$set('season', null);
|
|
||||||
}),
|
}),
|
||||||
Select::make('match_id')
|
Select::make('match_id')
|
||||||
->live()
|
->live()
|
||||||
@@ -355,7 +358,7 @@ 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-fill')
|
->prefixIcon('phosphor-calendar-star-fill')
|
||||||
->options(function (Get $get) {
|
->options(function (Get $get) {
|
||||||
return LoadSeasons::load($get('sofascore_category_id'));
|
return LoadSeasons::load($get('seasonmode'));
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function (callable $set) {
|
->afterStateUpdated(function (callable $set) {
|
||||||
$set('ss_player_id', null);
|
$set('ss_player_id', null);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class LoadEvents
|
|||||||
$team_id = (int) $filter['team_id'] ?? 0;
|
$team_id = (int) $filter['team_id'] ?? 0;
|
||||||
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
||||||
$team_position = $filter['team_position'];
|
$team_position = $filter['team_position'];
|
||||||
|
$seasonmode = $filter['seasonmode'];
|
||||||
$accuracy = (float) $filter['accuracy'] ?? 0.5;
|
$accuracy = (float) $filter['accuracy'] ?? 0.5;
|
||||||
$similar_past_matches = $filter['similar_past_matches'];
|
$similar_past_matches = $filter['similar_past_matches'];
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ class LoadEvents
|
|||||||
if ($similar_past_matches != 'none') {
|
if ($similar_past_matches != 'none') {
|
||||||
|
|
||||||
$team_id = 0;
|
$team_id = 0;
|
||||||
|
|
||||||
$team_position = '';
|
$team_position = '';
|
||||||
|
|
||||||
$exp_handicap = $match->exp_away - $match->exp_home;
|
$exp_handicap = $match->exp_away - $match->exp_home;
|
||||||
@@ -75,8 +76,10 @@ class LoadEvents
|
|||||||
/**
|
/**
|
||||||
* STATTISTIC DATA
|
* STATTISTIC DATA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$res = LoadEventsQuery::load($filter, $handicap_range, $total_range, $match);
|
$res = LoadEventsQuery::load($filter, $handicap_range, $total_range, $match);
|
||||||
|
|
||||||
|
|
||||||
$dataset_home = [];
|
$dataset_home = [];
|
||||||
$dataset_away = [];
|
$dataset_away = [];
|
||||||
$dataset_exp_home = [];
|
$dataset_exp_home = [];
|
||||||
@@ -104,7 +107,7 @@ class LoadEvents
|
|||||||
|
|
||||||
$playing_date[] = $value['starttime']->format('Y-m-d H:i');
|
$playing_date[] = $value['starttime']->format('Y-m-d H:i');
|
||||||
|
|
||||||
$results_per_event[] = $value['val_home'].' : '.$value['val_away'];
|
$results_per_event[] = $value['val_home'] . ' : ' . $value['val_away'];
|
||||||
|
|
||||||
$val_home = (int) $value['val_home'];
|
$val_home = (int) $value['val_home'];
|
||||||
$val_away = (int) $value['val_away'];
|
$val_away = (int) $value['val_away'];
|
||||||
@@ -203,7 +206,7 @@ class LoadEvents
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($val_home) && isset($val_away)) {
|
if (isset($val_home) && isset($val_away)) {
|
||||||
$events[] = $value['home'].' vs '.$value['away'];
|
$events[] = $value['home'] . ' vs ' . $value['away'];
|
||||||
|
|
||||||
if ($team_id == $value['home_id']) {
|
if ($team_id == $value['home_id']) {
|
||||||
$dataset_home[] = $val_home;
|
$dataset_home[] = $val_home;
|
||||||
@@ -223,16 +226,16 @@ class LoadEvents
|
|||||||
} else {
|
} else {
|
||||||
if ($team_id == $match->home->ss_team_id) {
|
if ($team_id == $match->home->ss_team_id) {
|
||||||
$label1 = $match->home->ss_team_name;
|
$label1 = $match->home->ss_team_name;
|
||||||
}else {
|
} else {
|
||||||
$label1 = $match->away->ss_team_name;
|
$label1 = $match->away->ss_team_name;
|
||||||
}
|
}
|
||||||
$label2 = 'Opponent';
|
$label2 = 'Opponent';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$label1 = $match->home->ss_team_name.' +';
|
$label1 = $match->home->ss_team_name . ' +';
|
||||||
$label2 = $match->home->ss_team_name.' -';
|
$label2 = $match->home->ss_team_name . ' -';
|
||||||
$label3 = $match->away->ss_team_name.' +';
|
$label3 = $match->away->ss_team_name . ' +';
|
||||||
$label4 = $match->away->ss_team_name.' -';
|
$label4 = $match->away->ss_team_name . ' -';
|
||||||
$dataset_home2 = [];
|
$dataset_home2 = [];
|
||||||
$dataset_away2 = [];
|
$dataset_away2 = [];
|
||||||
|
|
||||||
@@ -272,7 +275,7 @@ class LoadEvents
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$n = max(count($dataset_home), count($dataset_away), count($dataset_away2), count($dataset_home2));
|
$n = max(count($dataset_home), count($dataset_away), count($dataset_away2), count($dataset_home2));
|
||||||
if($n){
|
if ($n) {
|
||||||
$f = array_first($labels);
|
$f = array_first($labels);
|
||||||
$step = round($f / $n);
|
$step = round($f / $n);
|
||||||
$labels = [];
|
$labels = [];
|
||||||
@@ -330,7 +333,7 @@ class LoadEvents
|
|||||||
];
|
];
|
||||||
if ($team_id && $statistic_type == 'gls') {
|
if ($team_id && $statistic_type == 'gls') {
|
||||||
$data['datasets'][] = [
|
$data['datasets'][] = [
|
||||||
'label' => 'Goals '.$label1,
|
'label' => 'Goals ' . $label1,
|
||||||
'events' => $events,
|
'events' => $events,
|
||||||
'playing_date' => $playing_date,
|
'playing_date' => $playing_date,
|
||||||
'results_per_event' => $results_per_event,
|
'results_per_event' => $results_per_event,
|
||||||
@@ -342,7 +345,7 @@ class LoadEvents
|
|||||||
'hidden' => true,
|
'hidden' => true,
|
||||||
];
|
];
|
||||||
$data['datasets'][] = [
|
$data['datasets'][] = [
|
||||||
'label' => 'Goals '.$label2,
|
'label' => 'Goals ' . $label2,
|
||||||
'events' => $events,
|
'events' => $events,
|
||||||
'playing_date' => $playing_date,
|
'playing_date' => $playing_date,
|
||||||
'results_per_event' => $results_per_event,
|
'results_per_event' => $results_per_event,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class LoadEventsQuery
|
|||||||
$league_id = (int) $filter['league_id'] ?? 0;
|
$league_id = (int) $filter['league_id'] ?? 0;
|
||||||
$team_id = (int) $filter['team_id'] ?? 0;
|
$team_id = (int) $filter['team_id'] ?? 0;
|
||||||
$season = $filter['season'];
|
$season = $filter['season'];
|
||||||
$sofascore_category_id = $filter['sofascore_category_id'] ?? 0;
|
$seasonmode = $filter['seasonmode'];
|
||||||
$season_or_date = $filter['season_or_date'];
|
$season_or_date = $filter['season_or_date'];
|
||||||
$start = $filter['start_date'] ?? 0;
|
$start = $filter['start_date'] ?? 0;
|
||||||
$end = $filter['end_date'] ?? 0;
|
$end = $filter['end_date'] ?? 0;
|
||||||
@@ -37,9 +37,7 @@ class LoadEventsQuery
|
|||||||
// $team_id = 0;
|
// $team_id = 0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
$season = GetSeason::load($season, $sofascore_category_id);
|
$season = GetSeason::load($season, $seasonmode);
|
||||||
|
|
||||||
// dd($season);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IF WITH PLAYER
|
* IF WITH PLAYER
|
||||||
|
|||||||
Reference in new issue
Block a user