Update Media model

This commit is contained in:
Daniel Supernault 2018-11-03 21:19:22 -06:00
parent 3b7127ba32
commit fb24f382c0
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 17 additions and 2 deletions

View File

@ -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'];
}
}
}