/** * Store a newly created resource in storage. * * @return Response */ public function postIndex(Request $request) { $usuario = new User(); $inputs = $request->all(); $usuario->fill($inputs); if ($usuario->validate()) { if ($usuario->save()) { $usersGroup = Sentinel::findRoleById(2); $user = Sentinel::findUserById($usuario->id); $usersGroup->users()->attach($user); $this->generarActivationReminder($user, 'activation'); return redirect('login')->with('mensaje', 'Se registró el usuario correctamente'); } else { return back()->withInput()->withErrors($usuario->getErrors()); } } else { return back()->withInput()->withErrors($usuario->getErrors()); } }
/** * Find a user through Sentry by their ID. * * @param int|string $id * * @return bool|\Stevebauman\Maintenance\Models\User */ public function findUserById($id) { return Sentinel::findUserById($id); }