From 7a431af93ab89377cf3c6039f5932f0afbb98bd4 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 16 Jul 2023 04:24:58 -0600 Subject: [PATCH] Update Media model --- app/Media.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Media.php b/app/Media.php index 16448dbbf..b3f9ccba0 100644 --- a/app/Media.php +++ b/app/Media.php @@ -20,8 +20,8 @@ class Media extends Model protected $guarded = []; protected $casts = [ - 'srcset' => 'array', - 'deleted_at' => 'datetime' + 'srcset' => 'array', + 'deleted_at' => 'datetime' ]; public function status() @@ -63,7 +63,7 @@ class Media extends Model } if($this->media_path && $this->mime && in_array($this->mime, ['image/jpeg', 'image/png'])) { - return $this->remote_media || Str::startsWith($this->media_path, 'http') ? + return $this->remote_media || Str::startsWith($this->media_path, 'http') ? $this->media_path : url(Storage::url($this->media_path)); } @@ -78,6 +78,9 @@ class Media extends Model public function mimeType() { + if(!$this->mime) { + return; + } return explode('/', $this->mime)[0]; }