From 4e96bb5d32c7a142dcae25d01c9be69db22b63db Mon Sep 17 00:00:00 2001 From: liutk <961510893@qq.com> Date: Mon, 24 Jun 2024 23:06:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Resources/Api/UserGameResource.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Resources/Api/UserGameResource.php b/app/Http/Resources/Api/UserGameResource.php index a3c5c82..e69569a 100644 --- a/app/Http/Resources/Api/UserGameResource.php +++ b/app/Http/Resources/Api/UserGameResource.php @@ -45,10 +45,12 @@ class UserGameResource extends JsonResource return ($this->game?->state ?? 0) < 2 ?'0':($this->is_right ? '1':'2'); }, '0'), 'history' => $this->whenLoaded('userActivity', function () { - if($num = UserGame::where([ + if($num = UserGame::whereHas('game', function($q){ + return $q->where('state', 2); + })->where([ 'user_id' => $this->user_id, 'activity_id' => $this->activity_id, - ])->where('state', 2)->count() > 0) { + ])->count() > 0) { return $num.'δΈ­'.($this->userActivity->right_times ?? 0); }else{ return '';