diff --git a/app/Http/Controllers/Api/ActivityGameController.php b/app/Http/Controllers/Api/ActivityGameController.php index 8d90ec0..4c306d5 100644 --- a/app/Http/Controllers/Api/ActivityGameController.php +++ b/app/Http/Controllers/Api/ActivityGameController.php @@ -31,9 +31,9 @@ class ActivityGameController extends ApiController public function latestGame(Request $request) { - //获取最新的活动; - $activity = Activity::show()->sort()->first(); - $game = $activity?->games()->show() + $game = ActivityGame::whereHas('activity', function($q){ + return $q->where('state', '>' ,0); + })->show() ->whereDate('game_at', now()) ->where('game_at', '>', now()) ->where('state', 1) @@ -41,7 +41,9 @@ class ActivityGameController extends ApiController //若已经没有最新的活动了, 则拿取当天最后一个 if(!$game){ - $game = $activity?->games()->show() + $game = ActivityGame::whereHas('activity', function($q){ + return $q->where('state', '>' ,0); + })->show() ->whereDate('game_at', now()) ->orderBy('game_at', 'desc')->first(); }