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\LoadExpectations;
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class LoadEvents
|
||||
@@ -17,7 +15,6 @@ class LoadEvents
|
||||
$league_id = (int) $filter['league_id'] ?? 0;
|
||||
$match_id = (int) $filter['match_id'] ?? 0;
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
$season_or_date = $filter['season_or_date'] ?? 'season';
|
||||
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
||||
$team_position = $filter['team_position'];
|
||||
$accuracy = (float) $filter['accuracy'] ?? 0.5;
|
||||
@@ -34,16 +31,6 @@ class LoadEvents
|
||||
$statistic_type = 'gls';
|
||||
}
|
||||
|
||||
switch ($season_or_date) {
|
||||
case 'season':
|
||||
$start = 0;
|
||||
$end = 0;
|
||||
break;
|
||||
default:
|
||||
$season = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* IF WITH SIMILAR_PAST_MATCHES
|
||||
*
|
||||
@@ -80,7 +67,6 @@ class LoadEvents
|
||||
*/
|
||||
$res = LoadEventsQuery::load($filter, $handicap_range, $total_range, $match);
|
||||
|
||||
|
||||
$dataset_home = [];
|
||||
$dataset_away = [];
|
||||
$dataset_exp_home = [];
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Filament\Widgets\Data\LoadEvents;
|
||||
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use App\Models\StatistikoEvent;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class LoadEventsQuery
|
||||
$similar_past_matches = $filter['similar_past_matches'];
|
||||
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
||||
$team_position = $filter['team_position'];
|
||||
$season_or_date = $filter['season_or_date'] ?? 'season';
|
||||
$home_id = $match->home_id;
|
||||
$away_id = $match->away_id;
|
||||
|
||||
@@ -26,6 +27,16 @@ class LoadEventsQuery
|
||||
$statistic_type = 'gls';
|
||||
}
|
||||
|
||||
switch ($season_or_date) {
|
||||
case 'season':
|
||||
$start = 0;
|
||||
$end = 0;
|
||||
break;
|
||||
default:
|
||||
$season = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* IF WITH PLAYER
|
||||
*/
|
||||
@@ -99,9 +110,9 @@ class LoadEventsQuery
|
||||
})->when($total_range, function ($query) use ($total_range) {
|
||||
return $query->whereBetween('exp_total', $total_range);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
return $query->whereDate('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
return $query->whereDate('starttime', '<=', $end);
|
||||
})->when($season, function ($query) use ($season) {
|
||||
return $query->whereIn('season', $season);
|
||||
})
|
||||
|
||||
@@ -11,6 +11,7 @@ use Filament\Widgets\StatsOverviewWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Livewire\Attributes\Reactive;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class StatsMedianAverage extends StatsOverviewWidget
|
||||
{
|
||||
@@ -36,6 +37,37 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
|
||||
$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']);
|
||||
|
||||
$team_position = HelperTeamPosition::get($this->filters);
|
||||
@@ -126,48 +158,48 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
|
||||
$boxes = [];
|
||||
|
||||
// BOX 6
|
||||
$boxes[] = Stat::make($statistic_type, self::template('expectations_home', 'expectations_away', 'Home', 'Away', $expectations_home, $expectations_away))
|
||||
// BOX 1
|
||||
$boxes[] = Stat::make($statistic_type, self::template_2sp('expectations_home', 'expectations_away', 'Home', 'Away', $expectations_home, $expectations_away))
|
||||
->description('Expected Values')
|
||||
->extraAttributes([
|
||||
'class' => 'box-yellow',
|
||||
]);
|
||||
|
||||
if ($team_id) {
|
||||
// BOX 1
|
||||
$boxes[] = Stat::make('Total', new HtmlString('<div id="number-of-events">' . $total_home . '</div>'))
|
||||
->description('Events')
|
||||
// BOX 2
|
||||
|
||||
$boxes[] = Stat::make('Total', self::template_1sp('number-of-events', $total_home, 'Events'))
|
||||
->description(fn() => new HtmlString($date_events))
|
||||
->extraAttributes([
|
||||
'class' => 'box-info',
|
||||
]);
|
||||
// ->extraAttributes(['x-init' => "animate('number-of-events', $total_home, 0)"]);
|
||||
|
||||
// BOX 2
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('avhome', 'avaway', $home_team, $away_team, $value_home, $value_away))
|
||||
// BOX 3
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template_2sp('avhome', 'avaway', $home_team, $away_team, $value_home, $value_away))
|
||||
->description('Team ' . $team_position)
|
||||
->extraAttributes([
|
||||
'class' => 'box-success',
|
||||
]);
|
||||
// ->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away)"]);
|
||||
|
||||
// BOX 3
|
||||
// BOX 4
|
||||
// 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')
|
||||
->extraAttributes([
|
||||
'class' => 'box-success',
|
||||
]);
|
||||
// ->extraAttributes(['x-init' => "animate('av_team_home', $average_team_home); animate('av_team_away', $average_team_away)"]);
|
||||
|
||||
// BOX 4
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('av_league_home', 'av_league_away', 'Home', 'Away', $average_league_home, $average_league_away))
|
||||
// BOX 5
|
||||
$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')
|
||||
->extraAttributes([
|
||||
'class' => 'box-success',
|
||||
]);
|
||||
// ->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))
|
||||
->description($team_position)
|
||||
->extraAttributes([
|
||||
@@ -208,7 +240,15 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
</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">
|
||||
<span class="text-center" id="' . $home_id . '">' . $val_home . '</span>
|
||||
|
||||
Reference in new issue
Block a user