I have two models one Purchase.php and PurchaseItem.php
Purchase.php
public function purchase_items()
{
return $this->hasMany('PurchaseItem', 'purchase_id');
}
And PurchaseItem.php
public function purchase()
{
return $this->belongsTo('Purchase', 'purchase_id');
}
Users can purchase multiple items at a time that he wants. During update purchase, users can choose different items. In that case, some old items may remove and some new items added. So what is the best way to update the tables? I can remove all existing items and insert the newly added item during the update purchase. But I want to know the best practice in this case.
Thanks
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2RaVvVx
via IFTTT
Aucun commentaire:
Enregistrer un commentaire