Example #1
0
 /**
  * Update the specified team in storage.
  *
  * @param  int  $id id of team which should be updated
  * @return Response route where to redirect after update
  */
 public function update($id)
 {
     $team = Team::findOrFail($id);
     if (Auth::user()->id == $team->captain->id || Auth::user()->hasRole('admin')) {
         $validator = Validator::make(Input::all(), Team::rules($id));
         if ($validator->fails()) {
             return redirect('/teams/createForm')->withInput()->withErrors($validator);
         }
         $team->name = htmlspecialchars(Input::get('name'));
         $team->abbreviation = htmlspecialchars(Input::get('abbreviation'));
         $team->description = htmlspecialchars(Input::get('description'));
         $team->save();
         return redirect('/teams');
     } else {
         return redirect('/teams')->withErrors(trans('messages.not-captain-or-admin'));
     }
     //
 }