From 3053ae15953fd3aa3d239c47a32e36eca3f6bb1d Mon Sep 17 00:00:00 2001 From: Sebastiaan Speck Date: Tue, 16 Oct 2018 18:11:56 +0200 Subject: [PATCH] Only return top 10 topscorers from current_stage league Only return top 10 topscorers from current_stage league --- app/Http/Controllers/SoccerAPI/SoccerAPIController.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/Http/Controllers/SoccerAPI/SoccerAPIController.php b/app/Http/Controllers/SoccerAPI/SoccerAPIController.php index cad34ed2..ab9715b0 100644 --- a/app/Http/Controllers/SoccerAPI/SoccerAPIController.php +++ b/app/Http/Controllers/SoccerAPI/SoccerAPIController.php @@ -87,6 +87,15 @@ function leaguesDetails($leagueId, Request $request) if($league->coverage->topscorer_goals && !in_array($leagueId, $excludedLeagues)) { $topscorers = $soccerAPI->topscorers()->setInclude($includeTopscorers)->bySeasonId($league->current_season_id)->goalscorers->data; + + foreach($topscorers as $key => $topscorer) { + if($topscorer->stage_id != $league->current_stage_id) { + unset($topscorers[$key]); + } + } + + $topscorers = self::addPagination($topscorers, 10); + } $lastFixtures = [];