I want to sync pivot table in lavarel 5. When I create document, everything is fine, but when I want to update I get mysql error.
code with sync()
if($document->update(array('id' => $request->id, 'name' => $request->name))) {
$doc_ids = $request->documentation_appliance;
$document->appliances()->sync($doc_ids);
}
and I get this error
QueryException in Connection.php line 651:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'documentation_id' cannot be null (SQL: insert into `appliances_documentation` (`appliances_id`, `documentation_id`) values (6, ))
I though sync() will do everything, attach and detach, but seems like I am wrong. Can anyone tell me please a correct way how to do this? Thank you
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire