Fixed SQLSTATE[23000]: Integrity constraint violation: 19 CHECK constraint failed when deleting user

This commit is contained in:
Julian Prieber 2022-07-11 20:46:45 +02:00
parent 5f58a1f4ad
commit ceb65f6d17
1 changed files with 5 additions and 1 deletions

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Events\Registered;
use Illuminate\Support\Facades\Schema;
use Auth; use Auth;
use Exception; use Exception;
@ -135,7 +136,10 @@ class AdminController extends Controller
$id = $request->id; $id = $request->id;
$user = User::find($id); $user = User::find($id);
Schema::disableForeignKeyConstraints();
$user->forceDelete(); $user->forceDelete();
Schema::enableForeignKeyConstraints();
return redirect('panel/users/all'); return redirect('panel/users/all');
} }