From 7d7a64382b24d27efd0f6801b56a8ab6c29a361b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 18 Jun 2019 01:15:47 -0600 Subject: [PATCH] Update Status model --- app/Status.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Status.php b/app/Status.php index 2e2470e6f..769f0c719 100644 --- a/app/Status.php +++ b/app/Status.php @@ -150,9 +150,11 @@ class Status extends Model if(Auth::check() == false) { return false; } - 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(); + $user = Auth::user(); + $id = $this->id; + return Cache::remember('status:'.$this->id.':likedby:userid:'.$user->id, now()->addHours(30), function() use($user, $id) { + $profile = $user->profile; + return Like::whereProfileId($profile->id)->whereStatusId($id)->count(); }); } @@ -193,9 +195,12 @@ class Status extends Model if(Auth::check() == false) { return false; } - $profile = Auth::user()->profile; - - return self::whereProfileId($profile->id)->whereReblogOfId($this->id)->count(); + $user = Auth::user(); + $id = $this->id; + return Cache::remember('status:'.$this->id.':sharedby:userid:'.$user->id, now()->addHours(30), function() use($user, $id) { + $profile = $user->profile; + return self::whereProfileId($profile->id)->whereReblogOfId($id)->count(); + }); } public function sharedBy()