From ceb65f6d1709a7ac0c9fc2d80ebc4a6b71ace8c8 Mon Sep 17 00:00:00 2001 From: Julian Prieber <60265788+JulianPrieber@users.noreply.github.com> Date: Mon, 11 Jul 2022 20:46:45 +0200 Subject: [PATCH] Fixed SQLSTATE[23000]: Integrity constraint violation: 19 CHECK constraint failed when deleting user --- app/Http/Controllers/AdminController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 31c2a89..bf90af8 100755 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Hash; use Illuminate\Auth\Events\Registered; +use Illuminate\Support\Facades\Schema; use Auth; use Exception; @@ -134,8 +135,11 @@ class AdminController extends Controller { $id = $request->id; - $user = User::find($id); + $user = User::find($id); + + Schema::disableForeignKeyConstraints(); $user->forceDelete(); + Schema::enableForeignKeyConstraints(); return redirect('panel/users/all'); }