whereProfileId($profile_id) ->latest() ->get() ->each(function($like) use ($profile_id) { self::set($profile_id, $like->status_id); }); } public static function liked($profileId, $statusId) { $key = self::CACHE_KEY . $profileId; return (bool) Redis::zrank($key, $statusId); } public static function likedBy($status) { if(!$status->likes_count) { return [ 'username' => null, 'others' => false ]; } $id = Like::whereStatusId($status->id)->first()->profile_id; return [ 'username' => ProfileService::get($id)['username'], 'others' => $status->likes_count >= 5, ]; } }