/** * Determine if current user follows another user. * * @param User $user * @return bool */ public function isFollowedBy(User $user) { $idsOfUsersFollowed = $user->followedUsers()->lists('followed_id'); return in_array($this->id, $idsOfUsersFollowed); }
/** * Determine if current user follows another user. * * @param User $otherUser * @return bool */ public function isFollowedBy(User $otherUser) { $idsWhoOtherUserFollows = $otherUser->followedUsers()->lists('followed_id'); return $idsWhoOtherUserFollows->contains($this->id); }
/** * Determine if current user follows another user * * @param User $otherUser * @return bool */ public function isFollowedBy(User $otherUser) { $idsWhoOtherUserFollows = $otherUser->followedUsers()->lists('followed_id'); return in_array($this->id, $idsWhoOtherUserFollows); }
/** * Unfollow a Larabook user * @param $userIdToUnFollow * @param User $user * @return mixed */ public function unfollow($userIdToUnFollow, User $user) { return $user->followedUsers()->detach($userIdToUnFollow); }
/** * Unfollow a Larabook user. * * @param $userToUnfollow * @param User $followingUser * @return int */ public function unfollow($userToUnfollow, User $followingUser) { return $followingUser->followedUsers()->detach($userToUnfollow); }
/** * @param $idUserToUnfollow * @param User $user */ public function unfollow($idUserToUnfollow, User $user) { $user->followedUsers()->detach($idUserToUnfollow); }