From f98c7caff6258f33c80c1f55691d946ee7a3f8da Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 18 Jun 2019 00:48:40 -0600 Subject: [PATCH] Update Status model --- app/Status.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Status.php b/app/Status.php index f29e88e04..2e2470e6f 100644 --- a/app/Status.php +++ b/app/Status.php @@ -150,8 +150,10 @@ class Status extends Model if(Auth::check() == false) { return false; } - $profile = Auth::user()->profile; - return Like::whereProfileId($profile->id)->whereStatusId($this->id)->count(); + return Cache::remember('status:'.$this->id.':likedby:userid:'.Auth::id(), now()->addHours(30), function() { + $profile = Auth::user()->profile; + return Like::whereProfileId($profile->id)->whereStatusId($this->id)->count(); + }); } public function likedBy()