소스 검색

fixed:用户端-申请技师

刘学玺 3 달 전
부모
커밋
a8941bf02e
2개의 변경된 파일6개의 추가작업 그리고 10개의 파일을 삭제
  1. 5 5
      app/Models/CoachInfoRecord.php
  2. 1 5
      app/Services/Client/UserService.php

+ 5 - 5
app/Models/CoachInfoRecord.php

@@ -39,7 +39,7 @@ class CoachInfoRecord extends Model
      */
     public function getStateTextAttribute(): string
     {
-        return $this->state && TechnicianAuthStatus::fromValue($this->state)?->label() ?? '未知状态';
+        return TechnicianAuthStatus::fromValue($this->state)?->label() ?? '未知状态';
     }
 
     /**
@@ -51,8 +51,8 @@ class CoachInfoRecord extends Model
         return $this->belongsTo(CoachUser::class, 'coach_id', 'id');
     }
 
-    public function getStateAttribute($value)
-    {
-        return $value !== null ? TechnicianAuthStatus::fromValue($value) : null;
-    }
+    // public function getStateAttribute($value)
+    // {
+    //     return $value !== null ? TechnicianAuthStatus::fromValue($value) : null;
+    // }
 }

+ 1 - 5
app/Services/Client/UserService.php

@@ -241,11 +241,7 @@ class UserService
         );
 
         // 检查是否有正在审核的申请
-        $hasActiveApplication = CoachUser::where('user_id', $user->id)
-            ->whereHas('infoRecords', function ($query) {
-                $query->where('state', TechnicianAuthStatus::AUDITING->value);
-            })
-            ->exists();
+        $hasActiveApplication = $user->coach ? $user->coach->infoRecords()->where('state', TechnicianAuthStatus::AUDITING->value)->exists() : false;
 
         abort_if(
             $hasActiveApplication,