Skip to content

Commit ceb65f6

Browse files
committed
Fixed SQLSTATE[23000]: Integrity constraint violation: 19 CHECK constraint failed when deleting user
1 parent 5f58a1f commit ceb65f6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/Http/Controllers/AdminController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Http\Request;
66
use Illuminate\Support\Facades\Hash;
77
use Illuminate\Auth\Events\Registered;
8+
use Illuminate\Support\Facades\Schema;
89

910
use Auth;
1011
use Exception;
@@ -134,8 +135,11 @@ public function deleteUser(request $request)
134135
{
135136
$id = $request->id;
136137

137-
$user = User::find($id);
138+
$user = User::find($id);
139+
140+
Schema::disableForeignKeyConstraints();
138141
$user->forceDelete();
142+
Schema::enableForeignKeyConstraints();
139143

140144
return redirect('panel/users/all');
141145
}

0 commit comments

Comments
 (0)