I want to delete a faculty but I have this error
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (
trouverm_m_ecole.etablissement_filieres, CONSTRAINTetablissement_filieres_id_filieres_foreignFOREIGN KEY (id_filieres) REFERENCESfilieres(id)) (SQL: delete fromfiliereswhereid= 1)
My migration
Schema::create('etablissement_filieres', function (Blueprint $table) {
$table->id();
$table->bigInteger('id_etablissements')->unsigned();
$table->foreign('id_etablissements')->references('id')->on('etablissements');
$table->bigInteger('id_filieres')->unsigned();
$table->foreign('id_filieres')->references('id')->on('filieres');
$table->string('prise_en_charge');
$table->string('prix');
$table->string('prix_affecte')->nullable();
$table->timestamps();
});
my controller
public function destroy($id)
{
Filiere::destroy($id);
return redirect('/tableau-de-bord/admin/dashboard/sindhost/toutes-les-filieres');
}
Any ideas ?