public function updatePersonal(Request $request) { $user = User::findOrFail(Auth::user()->id); //dd($request->password); Validator::extend('passcheck', function ($attribute, $value, $parameters) { return Hash::check($value, Auth::user()->getAuthPassword()); }); $validator = Validator::make($request->all(), ['password' => 'required|confirmed|min:6', 'old_password' => 'required|passcheck|min:6'], ['passcheck' => 'Your old password was incorrect']); if ($validator->fails()) { return back()->withErrors($validator); } else { $user->password = bcrypt($request->password); $user->save(); $request->session()->flash('alert-success', 'Конфигурация успешно обновлена!'); return back(); } }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }