From fb24f382c0c4c64ccdf3deecb3ba2528473d6890 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 3 Nov 2018 21:19:22 -0600 Subject: [PATCH] Update Media model --- app/Media.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Media.php b/app/Media.php index 55cdd854..131f70a0 100644 --- a/app/Media.php +++ b/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']; + } + } }