public function edit($id, Request $request) { $user = User::findOrFail($id); if ($user->id != Auth::id()) { abort(403); } if ($user->bank == null) { Session::flash("flash_message", "You don't have a bank authorization to update."); return Redirect::route('user::dashboard', ['id' => $id]); } $bankdata = BankController::validateBankInput($request->all(), $user); if ($bankdata == false) { Session::flash("flash_message", "Your IBAN and/or BIC are invalid. Please check again."); return Redirect::back(); } $bank = Bank::create($bankdata); $user->bank()->delete(); $bank->user()->associate($user); $bank->save(); Session::flash("flash_message", "New withdrawal authorization added."); return Redirect::route('user::dashboard', ['id' => $id]); }
/** * Close a withdrawal so no more changes can be made. * * @param $id * @return \Illuminate\Http\RedirectResponse */ public static function close(Request $request, $id) { $withdrawal = Withdrawal::findOrFail($id); if ($withdrawal->closed) { $request->session()->flash('flash_message', 'This withdrawal is already closed and cannot be edited.'); return Redirect::back(); } foreach ($withdrawal->users() as $user) { if ($user->bank) { $user->bank->is_first = false; $user->bank->save(); } else { $user->backupBank->is_first = false; $user->backupBank->save(); } } $withdrawal->closed = true; $withdrawal->save(); foreach (Bank::onlyTrashed()->get() as $trashedBank) { if (!$trashedBank->user->hasUnpaidOrderlines()) { $trashedBank->forceDelete(); } } $request->session()->flash('flash_message', 'The withdrawal is now closed. Changes cannot be made anymore.'); return Redirect::back(); }
public function deleteUser(Request $request, $id) { $user = User::findOrFail($id); if ($user->id != Auth::id() && !Auth::user()->can('board')) { abort(403); } if ($user->member) { $request->session()->flash('flash_message', 'You cannot delete your account while you are a member.'); return Redirect::back(); } Address::where('user_id', $user->id)->delete(); Bank::where('user_id', $user->id)->delete(); EmailListSubscription::where('user_id', $user->id)->delete(); AchievementOwnership::where('user_id', $user->id)->delete(); Alias::where('user_id', $user->id)->delete(); RfidCard::where('user_id', $user->id)->delete(); WelcomeMessage::where('user_id', $user->id)->delete(); if ($user->photo) { $user->photo->delete(); } $user->password = null; $user->remember_token = null; $user->birthdate = null; $user->gender = null; $user->nationality = null; $user->phone = null; $user->website = null; $user->utwente_username = null; $user->tfa_totp_key = null; $user->tfa_yubikey_identity = null; $user->phone_visible = 0; $user->address_visible = 0; $user->receive_sms = 0; $user->save(); $user->delete(); $request->session()->flash('flash_message', 'Your account has been deleted.'); return Redirect::route('homepage'); }