Browse Source

feat:后台-视图模型-技师资质认证图片改为数组

刘学玺 3 months ago
parent
commit
d51a46192f
1 changed files with 36 additions and 12 deletions
  1. 36 12
      app/Models/VCoachAuthRecord.php

+ 36 - 12
app/Models/VCoachAuthRecord.php

@@ -97,31 +97,55 @@ class VCoachAuthRecord extends Model
     /**
      * 获取从业资格证完整URL
      */
-    public function getQualPhotoUrlAttribute(): ?string
+    public function getQualPhotoUrlAttribute(): ?array
     {
-        return $this->qual_photo
-            ? "/api/download?filename={$this->qual_photo}&bucket=user-avatar"
-            : null;
+        if (!$this->qual_photo) {
+            return null;
+        }
+
+        $images = is_string($this->qual_photo)
+            ? json_decode($this->qual_photo, true)
+            : $this->qual_photo;
+
+        return array_map(function ($image) {
+            return "/api/download?filename={$image}&bucket=user-avatar";
+        }, $images);
     }
 
     /**
      * 获取营业执照完整URL
      */
-    public function getBusinessLicenseUrlAttribute(): ?string
+    public function getBusinessLicenseUrlAttribute(): ?array
     {
-        return $this->business_license
-            ? "/api/download?filename={$this->business_license}&bucket=user-avatar"
-            : null;
+        if (!$this->business_license) {
+            return null;
+        }
+
+        $images = is_string($this->business_license)
+            ? json_decode($this->business_license, true)
+            : $this->business_license;
+
+        return array_map(function ($image) {
+            return "/api/download?filename={$image}&bucket=user-avatar";
+        }, $images);
     }
 
     /**
      * 获取健康证完整URL
      */
-    public function getHealthCertificateUrlAttribute(): ?string
+    public function getHealthCertificateUrlAttribute(): ?array
     {
-        return $this->health_certificate
-            ? "/api/download?filename={$this->health_certificate}&bucket=user-avatar"
-            : null;
+        if (!$this->health_certificate) {
+            return null;
+        }
+
+        $images = is_string($this->health_certificate)
+            ? json_decode($this->health_certificate, true)
+            : $this->health_certificate;
+
+        return array_map(function ($image) {
+            return "/api/download?filename={$image}&bucket=user-avatar";
+        }, $images);
     }
 
     /**