Im trying to implement a delete on my controller but then i have this error
Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (
greatsup_wz.entryitems, CONSTRAINTentryitems_fk_check_entry_idFOREIGN KEY (entry_id) REFERENCESentries(id)) (SQL: delete fromgreatsup_wz.entrieswhereid= 686)
Here is a piece of my code
$entryTable = DB::table(config("app.DB_ACCOUNTING").".entryitems")
->where('entryref_id','=',100)->get();
foreach($entryTable as $entryTbl):
DB::table(config("app.DB_ACCOUNTING").".entries")
->where('id','=',$entryTbl->entry_id)->delete(); // this is where my error occurred
endforeach;
How can i fix it ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire