Пример #1
0
 /**
  * Update the league in storage.
  *
  * @param  int  $id id of league which should be updated
  * @return Response route where to redirect after update
  */
 public function update($id)
 {
     $validator = Validator::make(Input::all(), League::rules($id));
     if ($validator->fails()) {
         return redirect('/leagues/createForm')->withInput()->withErrors($validator);
     }
     $league = League::findOrFail($id);
     $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->save();
     return redirect('/leagues');
     //
 }