diff --git a/app/Actions/LoadStatisticFixturesLeaguesOptions.php b/app/Actions/LoadStatisticFixturesLeaguesOptions.php index 6ca58aba..9b9a807d 100644 --- a/app/Actions/LoadStatisticFixturesLeaguesOptions.php +++ b/app/Actions/LoadStatisticFixturesLeaguesOptions.php @@ -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); diff --git a/app/Actions/LoadStatisticFixturesMatchOptions.php b/app/Actions/LoadStatisticFixturesMatchOptions.php index a7eda599..a384d37d 100644 --- a/app/Actions/LoadStatisticFixturesMatchOptions.php +++ b/app/Actions/LoadStatisticFixturesMatchOptions.php @@ -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; diff --git a/app/Console/Commands/Grapper/Sofascore/Rose.php b/app/Console/Commands/Grapper/Sofascore/Rose.php index 09d99007..b9ef27c5 100644 --- a/app/Console/Commands/Grapper/Sofascore/Rose.php +++ b/app/Console/Commands/Grapper/Sofascore/Rose.php @@ -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) { diff --git a/app/Filament/Imports/Helper/ImportEvents.php b/app/Filament/Imports/Helper/ImportEvents.php index 9f6217b9..4c842ebb 100644 --- a/app/Filament/Imports/Helper/ImportEvents.php +++ b/app/Filament/Imports/Helper/ImportEvents.php @@ -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, ] diff --git a/app/Filament/Widgets/Data/LoadEvents.php b/app/Filament/Widgets/Data/LoadEvents.php index b38040fc..1c0890f7 100644 --- a/app/Filament/Widgets/Data/LoadEvents.php +++ b/app/Filament/Widgets/Data/LoadEvents.php @@ -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'); diff --git a/app/Filament/Widgets/StatsMedianAverage.php b/app/Filament/Widgets/StatsMedianAverage.php index dd494e29..d2d5f4d5 100644 --- a/app/Filament/Widgets/StatsMedianAverage.php +++ b/app/Filament/Widgets/StatsMedianAverage.php @@ -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('
'.$total_home.'
')) + $boxes[] = Stat::make('Number', new HtmlString('
' . $total_home . '
')) ->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('
- '.number_format($win, 2).' - '.number_format($draw, 2).' - '.number_format($lost, 2).' - '.$name_win.' - '.$name_draw.' - '.$name_lost.' + ' . number_format($win, 2) . ' + ' . number_format($draw, 2) . ' + ' . number_format($lost, 2) . ' + ' . $name_win . ' + ' . $name_draw . ' + ' . $name_lost . '
'); } 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('
- '.$val_home.' - '.$val_away.' - '.$home_name.' - '.$away_name.' + ' . $val_home . ' + ' . $val_away . ' + ' . $home_name . ' + ' . $away_name . '
'); }