From be5b890ce79c639d58f7cd59e9ea7bd7bc7ee931 Mon Sep 17 00:00:00 2001 From: Julian Prieber <60265788+JulianPrieber@users.noreply.github.com> Date: Mon, 11 Jul 2022 16:25:26 +0200 Subject: [PATCH] Added proper option to delete users Users links will now NOT be deleted anymore if blocked. --- app/Http/Controllers/AdminController.php | 17 +++++++++++++---- resources/views/panel/users.blade.php | 11 +++++++++++ routes/web.php | 1 + 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 09d1616..31c2a89 100755 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -65,7 +65,7 @@ class AdminController extends Controller return view('panel/users', $data); } - //Block user and delete their links + //Block user public function blockUser(request $request) { $id = $request->id; @@ -79,8 +79,6 @@ class AdminController extends Controller User::where('id', $id)->update(['block' => $block]); - Link::where('user_id', $id)->delete(); - return redirect('panel/users/all'); } @@ -131,6 +129,17 @@ class AdminController extends Controller return redirect('panel/edit-user/'. $user->id); } + //Delete existing user + public function deleteUser(request $request) + { + $id = $request->id; + + $user = User::find($id); + $user->forceDelete(); + + return redirect('panel/users/all'); + } + //Show user to edit public function showUser(request $request) { @@ -191,7 +200,7 @@ class AdminController extends Controller $profilePhoto->move(base_path('/img'), $littlelink_name . ".png"); } - return back(); + return redirect('panel/users/all'); } //Show site pages to edit diff --git a/resources/views/panel/users.blade.php b/resources/views/panel/users.blade.php index 7c9e042..4e8bed0 100755 --- a/resources/views/panel/users.blade.php +++ b/resources/views/panel/users.blade.php @@ -27,6 +27,7 @@