Added proper option to delete users
Users links will now NOT be deleted anymore if blocked.
This commit is contained in:
parent
9a38e061c9
commit
be5b890ce7
|
@ -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
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<th scope="col">Links</th>
|
||||
@if(env('REGISTER_AUTH') !== 'auth')<th style="width:10%" scope="col">E-Mail Verified</th>@endif
|
||||
<th scope="col">Block</th>
|
||||
<th style="width:8%" scope="col">Delete user</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -39,6 +40,16 @@
|
|||
<td><a href="{{ route('showLinksUser', $user->id ) }}" class="text-primary">View</a></td>
|
||||
@if(env('REGISTER_AUTH') !== 'auth')<td><a href="{{ route('verifyUser', ['verify' => '-' . $user->email_verified_at, 'id' => $user->id] ) }}" class="text-danger">@if($user->email_verified_at == '')<span>no</span>@else<span style="color:#228B22">yes</span>@endif</a></td>@endif
|
||||
<td><a href="{{ route('blockUser', ['block' => $user->block, 'id' => $user->id] ) }}" class="text-danger">{{ $user->block }}</a></td>
|
||||
<td><a href="{{ route('deleteUser', ['id' => $user->id] ) }}" class="text-danger confirmation">Delete</a></td>
|
||||
<script type="text/javascript">
|
||||
var elems = document.getElementsByClassName('confirmation');
|
||||
var confirmIt = function (e) {
|
||||
if (!confirm('Are you sure you want to delete this user? \nThis action cannot be undone!')) e.preventDefault();
|
||||
};
|
||||
for (var i = 0, l = elems.length; i < l; i++) {
|
||||
elems[i].addEventListener('click', confirmIt, false);
|
||||
}
|
||||
</script>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue