소스 검색

Update Status model

Daniel Supernault 6 년 전
부모
커밋
f98c7caff6
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      app/Status.php

+ 4 - 2
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()