Update LikeService, fix likedBy method

pull/2747/head
Daniel Supernault 2021-05-03 17:55:06 -06:00
rodzic c10a94649c
commit a5e64da69b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 0DEF1C662C9033F7
1 zmienionych plików z 20 dodań i 6 usunięć

Wyświetl plik

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