/** * Get the feed for a user. * * @param User $user * @return mixed */ public function getFeedForUser(User $user) { $userIds = $user->followedUsers()->lists('followed_id'); $userIds[] = $user->id; return Status::with('comments')->whereIn('user_id', $userIds)->latest()->get(); }
public function isFollowedBy(User $otherUser) { $idsWithOtherUserFollows = $otherUser->followedUsers()->lists('followed_id'); $idsWithOtherUserFollows = array_values((array) $idsWithOtherUserFollows)[0]; return in_array($this->id, $idsWithOtherUserFollows); }