调整每日竞猜逻辑

main
liutk 2024-05-29 18:09:34 +08:00
parent a74f49fdbf
commit 696171e93d
1 changed files with 6 additions and 4 deletions

View File

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