/** * @param User $user * * @return bool */ public function userLikes(User $user) { $postId = $this->objectOrId instanceof Post ? $this->objectOrId->id : $this->objectOrId; return $user->likes()->where('postId', $postId)->count() > 0; }
/** * @param User $user * * @return bool * @throws Exception */ public function userLikes(User $user) { return $user->likes()->where('joinId', $this->objectOrId)->count() > 0; }
/** * @param User $user * * @return bool * @throws Exception */ public function userLikes(User $user) { $toDoId = $this->objectOrId instanceof ToDo ? $this->objectOrId->id : $this->objectOrId; return $user->likes()->where('toDoId', $toDoId)->count() > 0; }