parent
commit
66f876c1de
3 changed files with 17 additions and 2 deletions
  1. 1
    1
      app/Http/Controllers/Api/EsgController.php
  2. 1
    1
      app/Models/Banner.php
  3. 15
    0
      app/Models/UploadFile.php

+ 1
- 1
app/Http/Controllers/Api/EsgController.php View File

47
                                         ->orderBy("award_date", $request_ordering)
47
                                         ->orderBy("award_date", $request_ordering)
48
                                         ->orderBy("order", $request_ordering)->get()->map(function ($record) {
48
                                         ->orderBy("order", $request_ordering)->get()->map(function ($record) {
49
             return [
49
             return [
50
-                "uploadLink" => $record->upload_link,
50
+                "uploadLink" => $record->upload_file_link,
51
                 "awardDate" => "獲頒日期 : " . date("Y/m/d", strtotime($record->award_date))
51
                 "awardDate" => "獲頒日期 : " . date("Y/m/d", strtotime($record->award_date))
52
             ];
52
             ];
53
         });
53
         });

+ 1
- 1
app/Models/Banner.php View File

22
     protected function imgUrlLink(): Attribute
22
     protected function imgUrlLink(): Attribute
23
     {
23
     {
24
         return Attribute::make(
24
         return Attribute::make(
25
-            get: fn ($value) => is_null($this->ing_url) ? null :Storage::url($this->ing_url),
25
+            get: fn ($value) => is_null($this->img_url) ? null :Storage::url($this->img_url),
26
         );
26
         );
27
     }
27
     }
28
 }
28
 }

+ 15
- 0
app/Models/UploadFile.php View File

2
 
2
 
3
 namespace App\Models;
3
 namespace App\Models;
4
 
4
 
5
+use Illuminate\Database\Eloquent\Casts\Attribute;
5
 use Illuminate\Database\Eloquent\Model;
6
 use Illuminate\Database\Eloquent\Model;
7
+use Illuminate\Support\Facades\Storage;
6
 
8
 
7
 class UploadFile extends Model
9
 class UploadFile extends Model
8
 {
10
 {
11
+
9
     //
12
     //
13
+    protected $guarded  = ["id"];
14
+
15
+    public $appends = [
16
+        "upload_file_link"
17
+    ];
18
+
19
+    protected function uploadFileLink(): Attribute
20
+    {
21
+        return Attribute::make(
22
+            get: fn ($value) => is_null($this->upload_link) ? null :Storage::url($this->upload_link),
23
+        );
24
+    }
10
 }
25
 }