/** * Allows a user to delete their account. The force option can be used, if we are working with a model * that uses the soft deletes trait * * @param bool $force * * @return bool|int|mixed */ public function deleteAccount($force = false) { if ($force) { $this->user->forceDelete(); // log the user out $this->auth->logout(); return true; } else { $this->dataResult = $this->userRepository->delete([$this->user->id]); // log the user out $this->auth->logout(); return $this->dataResult; } }
/** * Show the form for editing the specified resource. * * @param int $id * * @return Response */ public function edit($id) { // get a user and their roles $user = $this->user->getFirstBy('id', '=', $id, ['roles']); return view('backend.access-control.RevokeRoles', compact('user')); }
/** * @param CreateUserAccountRequest $accountRequest * @return $this|\Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response */ public function store(CreateUserAccountRequest $accountRequest) { $this->data = $this->users->createAccount($accountRequest->except('accept'), false); return $this->handleRedirect($accountRequest, route('backend.users.index')); }
/** * This will allow users to optionally create an account before making an order * * @param GuestCreateAccount $guestCreateAccount * @param CreateAccount $user * * @param UserRepository $registerUser * @return mixed */ public function createAccount(GuestCreateAccount $guestCreateAccount, CreateAccount $user, UserRepository $registerUser) { // check the email $email = $this->guest->getGuestDetails()->email; $result = $registerUser->getFirstBy('email', '=', $email); if (!is_null($result)) { flash()->warning('Your email address is already in use. Please change it'); return redirect()->back(); } return $user->createAccount($guestCreateAccount, $registerUser)->handleRedirect($guestCreateAccount); }
/** * Enables a users account * * @param $user_id * @return bool */ public function enableAccount($user_id) { $user = $this->userRepository->find($user_id); $user->disabled = false; return $user->save(); }