From bb4e63eb59335999d60bf6366f339be1ecfa4410 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 9 Oct 2018 19:26:20 -0600 Subject: [PATCH] Update Status model --- app/Status.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/Status.php b/app/Status.php index bfbdeb4e6..70095d3f6 100644 --- a/app/Status.php +++ b/app/Status.php @@ -18,6 +18,8 @@ class Status extends Model */ protected $dates = ['deleted_at']; + protected $fillable = ['profile_id', 'visibility']; + public function profile() { return $this->belongsTo(Profile::class); @@ -36,16 +38,21 @@ class Status extends Model public function viewType() { $media = $this->firstMedia(); - $type = explode('/', $media->mime); + $mime = explode('/', $media->mime)[0]; + $count = $this->media()->count(); + $type = ($mime == 'image') ? 'image' : 'video'; + if($count > 1) { + $type = ($type == 'image') ? 'album' : 'video-album'; + } - return $type[0]; + return $type; } public function thumb($showNsfw = false) { $type = $this->viewType(); $is_nsfw = !$showNsfw ? $this->is_nsfw : false; - if ($this->media->count() == 0 || $is_nsfw || $type != 'image') { + if ($this->media->count() == 0 || $is_nsfw || !in_array($type,['image', 'album'])) { return 'data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=='; }