/** * Returns all the groups the user has joined. * @param $user * @param int $howMany * @return mixed */ public function groupsForUser($user, $howMany = 10) { $groupIds = $user->follows()->lists('group_id'); $groups = Group::whereIn('id', $groupIds)->simplePaginate($howMany); return $groups; }