|
@@ -50,13 +50,27 @@ class LikeService {
|
|
|
|
|
|
public static function likedBy($status)
|
|
|
{
|
|
|
+ $empty = [
|
|
|
+ 'username' => null,
|
|
|
+ 'others' => false
|
|
|
+ ];
|
|
|
+
|
|
|
+ if(!$status) {
|
|
|
+ return $empty;
|
|
|
+ }
|
|
|
+
|
|
|
if(!$status->likes_count) {
|
|
|
- return [
|
|
|
- 'username' => null,
|
|
|
- 'others' => false
|
|
|
- ];
|
|
|
+ return $empty;
|
|
|
}
|
|
|
- $id = Like::whereStatusId($status->id)->first()->profile_id;
|
|
|
+
|
|
|
+ $like = Like::whereStatusId($status->id)->first();
|
|
|
+
|
|
|
+ if(!$like) {
|
|
|
+ return $empty;
|
|
|
+ }
|
|
|
+
|
|
|
+ $id = $like->profile_id;
|
|
|
+
|
|
|
return [
|
|
|
'username' => ProfileService::get($id)['username'],
|
|
|
'others' => $status->likes_count >= 5,
|