コード例 #1
0
 /**
  * Store a newly created league in storage.
  *
  * @return Response route where to redirect after store
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), League::rules(""));
     if ($validator->fails()) {
         return redirect('/leagues/createForm')->withInput()->withErrors($validator);
     }
     $league = new League();
     $league->name = htmlspecialchars(Input::get('name'));
     $league->abbreviation = htmlspecialchars(Input::get('abbreviation'));
     $league->description = htmlspecialchars(Input::get('description'));
     $league->game()->associate(Game::findOrFail(Input::get('game_id')));
     $league->creator()->associate(Auth::user());
     //assign creator of league
     $league->save();
     return redirect('/leagues');
     //
 }