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_id
FOREIGN KEY (entry_id
) REFERENCESentries
(id
)) (SQL: delete fromgreatsup_wz
.entries
whereid
= 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