I'm trying to sync data to pivot table for my model. But my Recipe model has an hidden id field. Like this;
protected $hidden = ['id', 'content', 'difficulty_id'];
And when I try to sync relationships to pivot table, recipe_id becomes zero. If I remove id from $hidden above, it sync id without any problem. I also tried to call makeVisible("id") for the model but didn't help.
$changedMeals = $record->meals()->sync($meals);
How can I sync id when keeping it in $hidden?
Thank you very much...
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire