/** * Creamos el usuario a través del registro y le asignamos el rol de usuario */ public function showRegisterPost(RegisterRequest $request) { $form = collect_clean($request->all()); $request['password'] = bcrypt($request->password); $user = User::create($form->toArray()); $user->attachRole(2); alert('Cuenta creada correctamente, puede iniciar sesión'); return redirect()->route('showLogin'); }
public function store(UserRequest $request) { $form = collect_clean($request->all()); if ($request->has('birthday')) { $request['birthday'] = Carbon::createFromFormat('d/m/Y', $request->birthday)->format('Y-m-d'); } User::create($form->toArray()); alert('Usuario registrado correctamente'); return redirect()->back(); }