/** * Store a newly created team in storage. * * @return Response route where to redirect after store */ public function store() { $validator = Validator::make(Input::all(), Team::rules("")); if ($validator->fails()) { return redirect('/teams/createForm')->withInput()->withErrors($validator); } $team = new Team(); $team->name = htmlspecialchars(Input::get('name')); $team->abbreviation = htmlspecialchars(Input::get('abbreviation')); $team->description = htmlspecialchars(Input::get('description')); $team->captain()->associate(Auth::user()); //set creator as captain $team->save(); $team->members()->attach(Auth::user()); //addd him to the team return redirect('/teams'); // }