Пример #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $name = $request->name;
     $email = $request->email;
     $password = $request->password;
     $password_confirmation = $request->password_confirmation;
     $data = ['name' => $name, 'email' => $email, 'password' => $password, 'password_confirmation' => $password_confirmation];
     $validator = Validator::make($data, ['name' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
     if ($validator->fails()) {
         $redirect = '/users/' . $id . '/edit';
         return redirect($redirect)->withErrors($validator)->withInput();
     }
     $encr_password = Hash::make($password);
     $user = User::find($id);
     $user->name = $name;
     $user->email = $email;
     $user->password = $encr_password;
     $user->save();
     return redirect('/users/' . $id);
 }
Пример #2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($userId, $rtId)
 {
     $user = User::find($userId);
     $runningtime = Runningtime::find($rtId);
     return view('runningtimes.edit', ['user' => $user, 'rt' => $runningtime]);
 }