public function postForm(FormAdminRequest $request) { try { $dataAdmin = $request->all(); $password = $request->get('password', null); if (isset($dataAdmin['id']) && $dataAdmin['id'] != '') { $data = $request->except(array('password')); $runtime = User::find($dataAdmin['id']); $runtime->fill($data); $runtime->password = $runtime->password; if (!empty($password)) { $runtime->password = Hash::make($password); } $runtime->save(); $msg = 'Usuario Editado!'; } else { $role = Role::whereName(User::ROL_CONTENIDO_ADMIN)->first(); $dataAdmin['password'] = Hash::make($password); $NewUser = User::create($dataAdmin); $msg = 'Usuario Guardado!'; RoleUser::create(['user_id' => $NewUser->id, 'role_id' => $role->id]); } return redirect(action('Admin\\AdminController@getIndex'))->with('messageSuccess', $msg); } catch (Exception $exc) { dd($exc->getMessage()); } }
public function store(LoginAlternativeRequest $request) { try { $credentials['password'] = $request->input('idfacebook'); $credentials['email'] = $request->input('email'); $data['tokendevice'] = $request->input('tokendevice'); $data['typedevice'] = $request->input('typedevice'); $datauser = User::whereEmail($credentials['email'])->get()->first(); if (isset($datauser)) { if ($datauser->flagactive == User::STATE_USER_INACTIVE) { $this->_responseWS->setDataResponse(Response::HTTP_INTERNAL_SERVER_ERROR, [], [], 'usuario Inactivo'); $this->_responseWS->response(); } } else { $data = $request->all(); $data['password'] = Hash::make($data['idfacebook']); $obj = User::create($data); $datosRol = Role::whereName('user_app')->first(); $daoUserRol['role_id'] = (int) $datosRol->id; $daoUserRol['user_id'] = $obj->id; RoleUser::create($daoUserRol); } $this->login($request->all()); } catch (\Exception $exc) { dd($exc->getMessage()); $this->_responseWS->setDataResponse(Response::HTTP_INTERNAL_SERVER_ERROR, [], [], ''); } $this->_responseWS->response(); }
public function store(RegisterUserRequest $request) { try { $data = $request->all(); $data['password'] = Hash::make($data['idfacebook']); $obj = User::create($data); $datosRol = Role::whereName('user_app')->first(); $daoUserRol['role_id'] = (int) $datosRol->id; $daoUserRol['user_id'] = $obj->id; RoleUser::create($daoUserRol); $this->_responseWS->setDataResponse(Response::HTTP_CREATED, [['id' => $obj->id]], [], 'ok'); } catch (\Exception $exc) { dd($exc->getMessage()); $this->_responseWS->setDataResponse(Response::HTTP_INTERNAL_SERVER_ERROR, array(), array(), ''); } $this->_responseWS->response(); }
public function run() { RoleUser::create(['user_id' => 1, 'role_id' => 1]); }
/** * Adding role for user in special table * @param array $data * @return RoleUser */ public function createRoleUser(array $data) { RoleUser::create(['user_id' => User::all()->last()->id, 'role_id' => $data['role']]); }