Explorar o código

Update Media model

Daniel Supernault %!s(int64=6) %!d(string=hai) anos
pai
achega
fb24f382c0
Modificáronse 1 ficheiros con 17 adicións e 2 borrados
  1. 17 2
      app/Media.php

+ 17 - 2
app/Media.php

@@ -19,8 +19,12 @@ class Media extends Model
 
     public function url()
     {
-        $path = $this->media_path;
-        $url = Storage::url($path);
+        if(!empty($this->remote_media) && $this->remote_url) {
+            $url = $this->remote_url;
+        } else {
+            $path = $this->media_path;
+            $url = Storage::url($path);
+        }
 
         return url($url);
     }
@@ -60,4 +64,15 @@ class Media extends Model
     {
         return json_decode($this->metadata, true, 3);
     }
+
+    public function getModel()
+    {
+        if(empty($this->metadata)) {
+            return false;
+        }
+        $meta = $this->getMetadata();
+        if($meta && isset($meta['Model'])) {
+            return $meta['Model'];
+        }
+    }
 }