Browse Source

feat:后台-技师资质审核-添加图片url

刘学玺 3 months ago
parent
commit
c63723e76e
1 changed files with 36 additions and 0 deletions
  1. 36 0
      app/Models/CoachQualRecord.php

+ 36 - 0
app/Models/CoachQualRecord.php

@@ -23,6 +23,12 @@ class CoachQualRecord extends Model
      */
     protected string $stateEnumClass = TechnicianAuthStatus::class;
 
+    protected $appends = [
+        'qual_photo_url',           // 从业资格证
+        'business_license_url',      // 营业执照
+        'health_certificate_url'     // 健康证
+    ];
+
     /**
      * @Author FelixYin
      * @description 资质记录所属技师
@@ -31,4 +37,34 @@ class CoachQualRecord extends Model
     {
         return $this->belongsTo(CoachUser::class, 'coach_id', 'id');
     }
+
+    /**
+     * 获取从业资格证完整URL
+     */
+    public function getQualPhotoUrlAttribute(): ?string
+    {
+        return $this->qual_photo
+            ? "/api/download?filename={$this->qual_photo}&bucket=user-avatar"
+            : null;
+    }
+
+    /**
+     * 获取营业执照完整URL
+     */
+    public function getBusinessLicenseUrlAttribute(): ?string
+    {
+        return $this->business_license
+            ? "/api/download?filename={$this->business_license}&bucket=user-avatar"
+            : null;
+    }
+
+    /**
+     * 获取健康证完整URL
+     */
+    public function getHealthCertificateUrlAttribute(): ?string
+    {
+        return $this->health_certificate
+            ? "/api/download?filename={$this->health_certificate}&bucket=user-avatar"
+            : null;
+    }
 }