I have a N: N relationship and 3 tables: projeto
, pagamento
and projeto_pagamento
. In a form, I want to register a project and 5 payments, what would be the best way to accomplish this insertion?
I thought of doing a post in projeto
, posting an array to pagamento
, then getting the project ID and payment IDs in an array and making a post in projeto_pagamento
. Or would it be better to insert each separate payment instead of an array?
In this way you could use forEach
in the insert payment function and then projeto_pagamento
as well. Can you return the IDs of the inserted data?