public function reset_password($user_id, Request $request) { if ($request->password === $request->confirm_password) { $edit_user = $this->user->find($user_id); $edit_user->password = Hash::make($request->password); $edit_user->save(); $email_sent = UserEmail::send_email_password($edit_user); if ($email_sent) { \Session::flash('success', 'Contraseña actualizada'); return redirect('/profile'); } \Session::flash('error', 'No se pudo actualizar su contraseña'); return redirect('/profile'); } \Session::flash('error', 'Las contraseñas no coinciden'); return redirect('/profile'); }
public function store(UserRequest $request) { $generate_passsword = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 6); $new_user = new $this->user(); $new_user->name = $request->name; $new_user->email = $request->email; $new_user->password = Hash::make($generate_passsword); $new_user->is_active = true; $new_user->is_admin = $request->is_admin === "on" ? true : false; $new_user->save(); $email_sent = UserEmail::send_email($new_user, $generate_passsword); if ($email_sent) { \Session::flash('success', trans('users.user_registered')); return redirect('users'); } \Session::flash('error', trans('users.user_noregistered')); return redirect('users'); }