I'm updating a row in a table that in the migration is set up:
$table->integer('assigned_to')->unsigned()->nullable();
This row doesn't need to be assigned to a user so when creating the row the field is set as 'NULL'.
I'm now doing an update method where either a user id will be passed to the field or a null value if I wan't to 'un assign' the row.
Im getting an error regarding the foreign key (obviously...)
Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails
Is there anyway around this apart from removing the foreign key?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire