/** * Determine if the current user fallows other user * * @param User $otherUser * @return bool */ public function isFallowedBy(User $otherUser) { $idsWhoOtherUserFallows = $otherUser->fallowedUsers()->lists('fallowed_id'); return in_array($this->id, $idsWhoOtherUserFallows->toArray()); }
/** * Get the feed for a user. * * @param User $user * @return mixed */ public function getFeedForUser(User $user) { $userIds = $user->fallowedUsers()->lists('fallowed_id'); $userIds[] = $user->id; return Status::with('comments')->whereIn('user_id', $userIds)->latest()->get(); }