How to create/store and update associative models
I was wonder what the proper way was to create/store and update associative models.
Where I work we don’t use laravel but we basically do the following
$formData = [ 'first_name', 'last_name', 'invoice_address' = [ 'first_name', 'last_name', ]
So we have formdata for an order for example. Where I work we will create an order in the OrdersController and after succesfully saving it we will create an invoice_adress also in the OrdersController.
I read regularly that you should not deviate from the basic crud flow, so in my mind it makes sense to create an order in the OrdersController and after succesfully saving that, create an invoice_address in the InvoiceAddressesController and associate it with the newly created order.
So basically I’m wondering what the proper way is and how to achieve this in laravel?
submitted by /u/NotARandomRedditor
[link] [comments]
from Laravel Questions and Answers https://laravelquestions.com/rlaravel/how-to-create-store-and-update-associative-models/
via Lzo Media
No comments:
Post a Comment