wip
This commit is contained in:
1 parent
087b0a2a1a
commit
90b1dfdc4f
6 files changed
+57
-40
No files matched your search
@@ -7,7 +7,7 @@ use App\Models\StatisticFixtures;
|
||||
|
||||
class LoadStatisticFixturesLeaguesOptions
|
||||
{
|
||||
public static function load($sport_id)
|
||||
public static function load(int $sport_id)
|
||||
{
|
||||
$res = StatisticFixtures::where('sport_id', $sport_id)
|
||||
->groupBy('league_id')
|
||||
@@ -16,7 +16,7 @@ class LoadStatisticFixturesLeaguesOptions
|
||||
$cnt = CompetitionGroup::with('country')->whereIn('id', $res)->get();
|
||||
$arr = [];
|
||||
foreach ($cnt as $val) {
|
||||
$arr[$val->id] = $val->country->name.' '.$val->name;
|
||||
$arr[$val->id] = $val->country->name . ' ' . $val->name;
|
||||
}
|
||||
|
||||
asort($arr);
|
||||
|
||||
@@ -6,7 +6,7 @@ use App\Models\StatisticFixtures;
|
||||
|
||||
class LoadStatisticFixturesMatchOptions
|
||||
{
|
||||
public static function load($league_id)
|
||||
public static function load(int $league_id)
|
||||
{
|
||||
if (! $league_id) {
|
||||
return [];
|
||||
@@ -15,7 +15,7 @@ class LoadStatisticFixturesMatchOptions
|
||||
|
||||
$arr = [];
|
||||
foreach ($res as $val) {
|
||||
$arr[$val->id] = $val->starttime->format('Y-m-H H:i') . ' - ' . $val->home->name . ' vs ' . $val->away->name;
|
||||
$arr[$val->id] = $val->starttime->format('Y-m-d H:i') . ' - ' . $val->home->name . ' vs ' . $val->away->name;
|
||||
}
|
||||
|
||||
return $arr;
|
||||
|
||||
@@ -33,7 +33,9 @@ class Rose
|
||||
}
|
||||
}
|
||||
|
||||
$res = SofaScoreRosa::where('id', '>', 441)->get();
|
||||
// $res = SofaScoreRosa::where('id', '>', 441)->get();
|
||||
|
||||
$res = SofaScoreRosa::get();
|
||||
|
||||
foreach ($res as $value) {
|
||||
|
||||
|
||||
@@ -25,7 +25,13 @@ class ImportEvents
|
||||
* must be != null
|
||||
* exp_home, exp_away, exp_handicap, exp_total
|
||||
*/
|
||||
if ((float) $row[21] != 0 && (float) $row[22] != 0 && (float) $row[23] != 0) {
|
||||
if (
|
||||
(float) $row[21] != 0
|
||||
&& (float) $row[22] != 0
|
||||
&& (float) $row[23] != 0
|
||||
&& (float) $row[24] != 0
|
||||
&& (string) $row[25] != ''
|
||||
) {
|
||||
|
||||
StatistikoEvent::updateOrCreate(
|
||||
[
|
||||
@@ -56,7 +62,7 @@ class ImportEvents
|
||||
'exp_away' => (float) $row[22],
|
||||
'exp_handicap' => (float) $row[23],
|
||||
'exp_total' => (float) $row[24],
|
||||
'result_code' => $row[25], // w, d, l
|
||||
'result_code' => (string) $row[25], // w, d, l
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LoadEvents
|
||||
{
|
||||
@@ -20,7 +21,7 @@ class LoadEvents
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
|
||||
$season_or_date = $filter['season_or_date'] ?? 'season';
|
||||
|
||||
|
||||
$season = $filter['season'] ?? 0;
|
||||
|
||||
$tm_player_id = (int) $filter['tm_player_id'] ?? 0;
|
||||
@@ -95,7 +96,7 @@ class LoadEvents
|
||||
*/
|
||||
$matches_played = [];
|
||||
$description = '';
|
||||
|
||||
|
||||
if ($tm_player_id) {
|
||||
|
||||
$matches_season = StatistikoEvent::where(function ($query) use ($team_id, $team_position) {
|
||||
@@ -110,15 +111,15 @@ class LoadEvents
|
||||
}
|
||||
})->pluck('match_id')->toArray();
|
||||
|
||||
|
||||
|
||||
$matches_played = StatistikoPlayer::query()
|
||||
->whereIn('match_id', $matches_season)
|
||||
->where('tm_player_id', '=', (int) $tm_player_id)
|
||||
->when($player_on_field, function ($query) use ($player_on_field) {
|
||||
// 'all' => 'All',
|
||||
// 'lineup' => 'Lineup',
|
||||
// 'substituted' => 'Substituted',
|
||||
// 'notplayed' => 'Not Played',
|
||||
// 'all' => 'All',
|
||||
// 'lineup' => 'Lineup',
|
||||
// 'substituted' => 'Substituted',
|
||||
// 'notplayed' => 'Not Played',
|
||||
switch ($player_on_field) {
|
||||
case 'all':
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
@@ -164,9 +165,9 @@ class LoadEvents
|
||||
}
|
||||
}
|
||||
})->when($matches_played, function ($query) use ($matches_played, $player_on_field) {
|
||||
if($player_on_field == 'notplayed'){
|
||||
if ($player_on_field == 'notplayed') {
|
||||
return $query->whereNotIn('match_id', $matches_played);
|
||||
}else {
|
||||
} else {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
}
|
||||
})->when($handicap_range, function ($query) use ($handicap_range) {
|
||||
@@ -177,7 +178,7 @@ class LoadEvents
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})->when($season , function ($query) use ($season) {
|
||||
})->when($season, function ($query) use ($season) {
|
||||
return $query->whereIn('season', $season);
|
||||
})
|
||||
->orderBy('starttime', 'ASC')
|
||||
@@ -187,6 +188,9 @@ class LoadEvents
|
||||
return [];
|
||||
}
|
||||
|
||||
// Log::debug($res->toArray());
|
||||
|
||||
|
||||
$dataset_home = [];
|
||||
$dataset_away = [];
|
||||
$dataset_exp_home = [];
|
||||
@@ -201,6 +205,10 @@ class LoadEvents
|
||||
|
||||
// dd($value);
|
||||
|
||||
// $result_code = (string) $value['result_code'];
|
||||
|
||||
// Log::debug($result_code);
|
||||
|
||||
$labels[] = round($value['starttime']->diffInDays(Carbon::now()));
|
||||
|
||||
$playing_date[] = $value['starttime']->format('d. F Y H:i');
|
||||
|
||||
@@ -9,7 +9,7 @@ use App\Utilities\Round;
|
||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||
use Filament\Widgets\StatsOverviewWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
// use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Livewire\Attributes\Reactive;
|
||||
|
||||
@@ -80,6 +80,7 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
}
|
||||
|
||||
if (isset($data['results'])) {
|
||||
// Log::debug($data['results']);
|
||||
$win = $data['results']['w'] ? number_format(Round::odd($total_home / $data['results']['w']), 2) : 0;
|
||||
$draw = $data['results']['d'] ? number_format(Round::odd($total_home / $data['results']['d']), 2) : 0;
|
||||
$lost = $data['results']['l'] ? number_format(Round::odd($total_home / $data['results']['l']), 2) : 0;
|
||||
@@ -119,22 +120,22 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
|
||||
$boxes = [];
|
||||
// BOX 1
|
||||
$boxes[] = Stat::make('Number', new HtmlString('<div id="number-of-events">'.$total_home.'</div>'))
|
||||
$boxes[] = Stat::make('Number', new HtmlString('<div id="number-of-events">' . $total_home . '</div>'))
|
||||
->description('Events')
|
||||
->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))
|
||||
->description('Team '.$team_position)
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('avhome', 'avaway', $home_team, $away_team))
|
||||
->description('Team ' . $team_position)
|
||||
->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away)"]);
|
||||
|
||||
// BOX 3
|
||||
$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('av_team_home', 'av_team_away', $home_team, $away_team, $average_team_home, $average_team_away))
|
||||
->description('Team Season')
|
||||
->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))
|
||||
$boxes[] = Stat::make('Average ' . $statistic_type, self::template('av_league_home', 'av_league_away', 'Home', 'Away', $average_league_home, $average_league_away))
|
||||
->description('League Season')
|
||||
->extraAttributes(['x-init' => "animate('av_league_home', $average_league_home); animate('av_league_away', $average_league_away)"]);
|
||||
|
||||
@@ -154,35 +155,35 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
return $boxes;
|
||||
}
|
||||
|
||||
protected function templateOdds(&$data, float $win, float $draw, float $lost): HtmlString
|
||||
protected function templateOdds(array &$data, float $win, float $draw, float $lost): HtmlString
|
||||
{
|
||||
if ($data['similar_past_matches'] != 'none') {
|
||||
$name_win = '1 ('.$data['results']['w'].')';
|
||||
$name_draw = 'X ('.$data['results']['d'].')';
|
||||
$name_lost = '2 ('.$data['results']['l'].')';
|
||||
$name_win = '1 (' . $data['results']['w'] . ')';
|
||||
$name_draw = 'X (' . $data['results']['d'] . ')';
|
||||
$name_lost = '2 (' . $data['results']['l'] . ')';
|
||||
} else {
|
||||
$name_win = 'Win ('.$data['results']['w'].')';
|
||||
$name_draw = 'Draw ('.$data['results']['d'].')';
|
||||
$name_lost = 'Lost ('.$data['results']['l'].')';
|
||||
$name_win = 'Win (' . $data['results']['w'] . ')';
|
||||
$name_draw = 'Draw (' . $data['results']['d'] . ')';
|
||||
$name_lost = 'Lost (' . $data['results']['l'] . ')';
|
||||
}
|
||||
|
||||
return new HtmlString('<div class="grid grid-cols-3 justify-center">
|
||||
<span class="text-center font-bold text-xl">'.number_format($win, 2).'</span>
|
||||
<span class="text-center font-bold text-xl">'.number_format($draw, 2).'</span>
|
||||
<span class="text-center font-bold text-xl">'.number_format($lost, 2).'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$name_win.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$name_draw.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$name_lost.'</span>
|
||||
<span class="text-center font-bold text-xl">' . number_format($win, 2) . '</span>
|
||||
<span class="text-center font-bold text-xl">' . number_format($draw, 2) . '</span>
|
||||
<span class="text-center font-bold text-xl">' . number_format($lost, 2) . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $name_win . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $name_draw . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $name_lost . '</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
protected function template(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>
|
||||
<span class="text-center" id="'.$away_id.'">'.$val_away.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$home_name.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$away_name.'</span>
|
||||
<span class="text-center" id="' . $home_id . '">' . $val_home . '</span>
|
||||
<span class="text-center" id="' . $away_id . '">' . $val_away . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $home_name . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $away_name . '</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user