fix date box selection
This commit is contained in:
1 parent
d8bb8153d9
commit
d746d34271
4 files changed
+67
-31
No files matched your search
@@ -6,8 +6,6 @@ use App\Filament\Widgets\Data\LoadEvents\LoadEventsAverages;
|
|||||||
use App\Filament\Widgets\Data\LoadEvents\LoadEventsQuery;
|
use App\Filament\Widgets\Data\LoadEvents\LoadEventsQuery;
|
||||||
use App\Filament\Widgets\Data\LoadEvents\LoadExpectations;
|
use App\Filament\Widgets\Data\LoadEvents\LoadExpectations;
|
||||||
use App\Models\StatisticFixtures;
|
use App\Models\StatisticFixtures;
|
||||||
use App\Models\StatistikoEvent;
|
|
||||||
use App\Models\StatistikoPlayer;
|
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
class LoadEvents
|
class LoadEvents
|
||||||
@@ -17,7 +15,6 @@ class LoadEvents
|
|||||||
$league_id = (int) $filter['league_id'] ?? 0;
|
$league_id = (int) $filter['league_id'] ?? 0;
|
||||||
$match_id = (int) $filter['match_id'] ?? 0;
|
$match_id = (int) $filter['match_id'] ?? 0;
|
||||||
$team_id = (int) $filter['team_id'] ?? 0;
|
$team_id = (int) $filter['team_id'] ?? 0;
|
||||||
$season_or_date = $filter['season_or_date'] ?? 'season';
|
|
||||||
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
||||||
$team_position = $filter['team_position'];
|
$team_position = $filter['team_position'];
|
||||||
$accuracy = (float) $filter['accuracy'] ?? 0.5;
|
$accuracy = (float) $filter['accuracy'] ?? 0.5;
|
||||||
@@ -34,16 +31,6 @@ class LoadEvents
|
|||||||
$statistic_type = 'gls';
|
$statistic_type = 'gls';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($season_or_date) {
|
|
||||||
case 'season':
|
|
||||||
$start = 0;
|
|
||||||
$end = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$season = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IF WITH SIMILAR_PAST_MATCHES
|
* IF WITH SIMILAR_PAST_MATCHES
|
||||||
*
|
*
|
||||||
@@ -80,7 +67,6 @@ class LoadEvents
|
|||||||
*/
|
*/
|
||||||
$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 = [];
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Filament\Widgets\Data\LoadEvents;
|
namespace App\Filament\Widgets\Data\LoadEvents;
|
||||||
|
|
||||||
use App\Models\CompetitionGroup;
|
|
||||||
use App\Models\SofaScoreTournament;
|
use App\Models\SofaScoreTournament;
|
||||||
use App\Models\StatistikoEvent;
|
use App\Models\StatistikoEvent;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class LoadEventsQuery
|
|||||||
$similar_past_matches = $filter['similar_past_matches'];
|
$similar_past_matches = $filter['similar_past_matches'];
|
||||||
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
||||||
$team_position = $filter['team_position'];
|
$team_position = $filter['team_position'];
|
||||||
|
$season_or_date = $filter['season_or_date'] ?? 'season';
|
||||||
$home_id = $match->home_id;
|
$home_id = $match->home_id;
|
||||||
$away_id = $match->away_id;
|
$away_id = $match->away_id;
|
||||||
|
|
||||||
@@ -26,6 +27,16 @@ class LoadEventsQuery
|
|||||||
$statistic_type = 'gls';
|
$statistic_type = 'gls';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch ($season_or_date) {
|
||||||
|
case 'season':
|
||||||
|
$start = 0;
|
||||||
|
$end = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$season = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IF WITH PLAYER
|
* IF WITH PLAYER
|
||||||
*/
|
*/
|
||||||
@@ -99,9 +110,9 @@ class LoadEventsQuery
|
|||||||
})->when($total_range, function ($query) use ($total_range) {
|
})->when($total_range, function ($query) use ($total_range) {
|
||||||
return $query->whereBetween('exp_total', $total_range);
|
return $query->whereBetween('exp_total', $total_range);
|
||||||
})->when($start, function ($query) use ($start) {
|
})->when($start, function ($query) use ($start) {
|
||||||
return $query->where('starttime', '>=', $start);
|
return $query->whereDate('starttime', '>=', $start);
|
||||||
})->when($end, function ($query) use ($end) {
|
})->when($end, function ($query) use ($end) {
|
||||||
return $query->where('starttime', '<=', $end);
|
return $query->whereDate('starttime', '<=', $end);
|
||||||
})->when($season, function ($query) use ($season) {
|
})->when($season, function ($query) use ($season) {
|
||||||
return $query->whereIn('season', $season);
|
return $query->whereIn('season', $season);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use Filament\Widgets\StatsOverviewWidget;
|
|||||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
use Livewire\Attributes\Reactive;
|
use Livewire\Attributes\Reactive;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
class StatsMedianAverage extends StatsOverviewWidget
|
class StatsMedianAverage extends StatsOverviewWidget
|
||||||
{
|
{
|
||||||
@@ -36,6 +37,37 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
|
|
||||||
$team_id = (int) $this->filters['team_id'] ?? 0;
|
$team_id = (int) $this->filters['team_id'] ?? 0;
|
||||||
|
|
||||||
|
$season = $this->filterss['season'] ?? 0;
|
||||||
|
$season_or_date = $this->filters['season_or_date'];
|
||||||
|
$date_events = '';
|
||||||
|
switch ($season_or_date) {
|
||||||
|
case 'season':
|
||||||
|
if ($season)
|
||||||
|
$date_events = implode(',', $season);
|
||||||
|
else
|
||||||
|
$date_events = 'All Seasons' . $season_or_date;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$start = $this->filters['start_date'] ?? 0;
|
||||||
|
$end = $this->filters['end_date'] ?? 0;
|
||||||
|
|
||||||
|
$tmp = [];
|
||||||
|
if ($start) {
|
||||||
|
$tmp[] = 'From: ' . Carbon::createFromDate($start)->format('Y-m-d');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($end)
|
||||||
|
$tmp[] = 'To: ' . Carbon::createFromDate($end)->format('Y-m-d');
|
||||||
|
|
||||||
|
if ($tmp)
|
||||||
|
$date_events = implode('<br>', $tmp);
|
||||||
|
else
|
||||||
|
$date_events = 'All Dates';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Log::debug($data['datasets']);
|
// Log::debug($data['datasets']);
|
||||||
|
|
||||||
$team_position = HelperTeamPosition::get($this->filters);
|
$team_position = HelperTeamPosition::get($this->filters);
|
||||||
@@ -126,48 +158,48 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
|
|
||||||
$boxes = [];
|
$boxes = [];
|
||||||
|
|
||||||
// BOX 6
|
// BOX 1
|
||||||
$boxes[] = Stat::make($statistic_type, self::template('expectations_home', 'expectations_away', 'Home', 'Away', $expectations_home, $expectations_away))
|
$boxes[] = Stat::make($statistic_type, self::template_2sp('expectations_home', 'expectations_away', 'Home', 'Away', $expectations_home, $expectations_away))
|
||||||
->description('Expected Values')
|
->description('Expected Values')
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
'class' => 'box-yellow',
|
'class' => 'box-yellow',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($team_id) {
|
if ($team_id) {
|
||||||
// BOX 1
|
// BOX 2
|
||||||
$boxes[] = Stat::make('Total', new HtmlString('<div id="number-of-events">' . $total_home . '</div>'))
|
|
||||||
->description('Events')
|
$boxes[] = Stat::make('Total', self::template_1sp('number-of-events', $total_home, 'Events'))
|
||||||
|
->description(fn() => new HtmlString($date_events))
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
'class' => 'box-info',
|
'class' => 'box-info',
|
||||||
]);
|
]);
|
||||||
// ->extraAttributes(['x-init' => "animate('number-of-events', $total_home, 0)"]);
|
|
||||||
|
|
||||||
// BOX 2
|
// BOX 3
|
||||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('avhome', 'avaway', $home_team, $away_team, $value_home, $value_away))
|
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_2sp('avhome', 'avaway', $home_team, $away_team, $value_home, $value_away))
|
||||||
->description('Team ' . $team_position)
|
->description('Team ' . $team_position)
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
'class' => 'box-success',
|
'class' => 'box-success',
|
||||||
]);
|
]);
|
||||||
// ->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away)"]);
|
// ->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away)"]);
|
||||||
|
|
||||||
// BOX 3
|
// BOX 4
|
||||||
// Log::debug([$average_team_home, $average_team_away]);
|
// Log::debug([$average_team_home, $average_team_away]);
|
||||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('av_team_home', 'av_team_away', $home_team, $away_team, $average_team_home, $average_team_away))
|
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_2sp('av_team_home', 'av_team_away', $home_team, $away_team, $average_team_home, $average_team_away))
|
||||||
->description('Team Season')
|
->description('Team Season')
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
'class' => 'box-success',
|
'class' => 'box-success',
|
||||||
]);
|
]);
|
||||||
// ->extraAttributes(['x-init' => "animate('av_team_home', $average_team_home); animate('av_team_away', $average_team_away)"]);
|
// ->extraAttributes(['x-init' => "animate('av_team_home', $average_team_home); animate('av_team_away', $average_team_away)"]);
|
||||||
|
|
||||||
// BOX 4
|
// BOX 5
|
||||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('av_league_home', 'av_league_away', 'Home', 'Away', $average_league_home, $average_league_away))
|
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_2sp('av_league_home', 'av_league_away', 'Home', 'Away', $average_league_home, $average_league_away))
|
||||||
->description('League Season')
|
->description('League Season')
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
'class' => 'box-success',
|
'class' => 'box-success',
|
||||||
]);
|
]);
|
||||||
// ->extraAttributes(['x-init' => "animate('av_league_home', $average_league_home); animate('av_league_away', $average_league_away)"]);
|
// ->extraAttributes(['x-init' => "animate('av_league_home', $average_league_home); animate('av_league_away', $average_league_away)"]);
|
||||||
|
|
||||||
// BOX 5
|
// BOX 6
|
||||||
$boxes[] = Stat::make('Odds', self::templateOdds($data, $win, $draw, $lost))
|
$boxes[] = Stat::make('Odds', self::templateOdds($data, $win, $draw, $lost))
|
||||||
->description($team_position)
|
->description($team_position)
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
@@ -208,7 +240,15 @@ class StatsMedianAverage extends StatsOverviewWidget
|
|||||||
</div>');
|
</div>');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function template(string $home_id, string $away_id, string $home_name, string $away_name, $val_home = 0, $val_away = 0): HtmlString
|
protected function template_1sp(string $value_id, string $value, $text = 0): HtmlString
|
||||||
|
{
|
||||||
|
return new HtmlString('<div class="grid grid-cols-1 justify-center font-bold text-2xl">
|
||||||
|
<span class="text-center" id="' . $value_id . '">' . $value . '</span>
|
||||||
|
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $text . '</span>
|
||||||
|
</div>');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function template_2sp(string $home_id, string $away_id, string $home_name, string $away_name, $val_home = 0, $val_away = 0): HtmlString
|
||||||
{
|
{
|
||||||
return new HtmlString('<div class="grid grid-cols-2 justify-center font-bold text-2xl">
|
return new HtmlString('<div class="grid grid-cols-2 justify-center font-bold text-2xl">
|
||||||
<span class="text-center" id="' . $home_id . '">' . $val_home . '</span>
|
<span class="text-center" id="' . $home_id . '">' . $val_home . '</span>
|
||||||
|
|||||||
Reference in new issue
Block a user