laravel-and-vue.js-spa-Recipe-Box
laravel-and-vue.js-spa-Recipe-Box copied to clipboard
Delete all not updated against sync()
Hello. You are using
RecipeIngredient::whereNotIn('id',$ingredients_updated)
->where('recipe_id',$recipe->id)
->delete();
RecipeDirection::whereNotIn('id',$directions_updated)
->where('recipe_id',$recipe->id)
->delete();
and why not just
$recipe->ingredients()->sync($ingredients_updated);
$recipe->directions()->sync($directions_updated);
insted?
@Sebbba i didnt know about this. Are you sure this works? I will test this later
@anishdcruz https://laravel.com/docs/5.5/eloquent-relationships Syncing Associations - chapter.