/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $message = WelcomeMessage::find($id); if (!$message) { abort(404); } $message->delete(); Session::flash('flash_message', "Welcome Message removed"); return Redirect::route("welcomeMessages::list"); }
/** * Display the homepage. */ public function show() { $events = Event::where('secret', false)->where('start', '>=', date('U'))->orderBy('start')->limit(5)->get(); $companies = Company::where('in_logo_bar', true)->get(); if (Auth::check()) { $message = WelcomeMessage::where('user_id', Auth::user()->id)->first(); return view('website.home.members', ['events' => $events, 'companies' => $companies, 'message' => $message]); } else { return view('website.home.external', ['events' => $events, 'companies' => $companies]); } }
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'); }