/** * Get all of the teams for the user. * * @param \Illuminate\Contracts\Auth\Authenticatable $user * @return \Illuminate\Database\Eloquent\Collection */ public function getAllTeamsForUser($user) { $teams = $user->teams()->with('owner')->get(); foreach ($teams as $team) { $team->owner->setVisible(['name']); } return $teams; }