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 @@ Links @if(env('REGISTER_AUTH') !== 'auth')E-Mail Verified@endif Block + Delete user @@ -39,6 +40,16 @@ View @if(env('REGISTER_AUTH') !== 'auth')@if($user->email_verified_at == '')no@elseyes@endif@endif {{ $user->block }} + Delete + @endforeach diff --git a/routes/web.php b/routes/web.php index 5a3bfaf..bf91927 100755 --- a/routes/web.php +++ b/routes/web.php @@ -102,6 +102,7 @@ Route::get('/panel/users/verify/-{verify}/{id}', [AdminController::class, 'verif Route::get('/panel/edit-user/{id}', [AdminController::class, 'showUser'])->name('showUser'); Route::post('/panel/edit-user/{id}', [AdminController::class, 'editUser'])->name('editUser'); Route::get('/panel/new-user', [AdminController::class, 'createNewUser'])->name('createNewUser'); +Route::get('/panel/delete-user/{id}', [AdminController::class, 'deleteUser'])->name('deleteUser'); Route::get('/panel/pages', [AdminController::class, 'showSitePage'])->name('showSitePage'); Route::post('/panel/pages', [AdminController::class, 'editSitePage'])->name('editSitePage'); Route::get('/panel/advanced-config', [AdminController::class, 'showFileEditor'])->name('showFileEditor');