소스 검색

fixed:模型修复

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

+ 6 - 1
app/Models/CoachInfoRecord.php

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