What is preventing you writing the code in that order?
If you want to get creative, you can refactor to a Pipeline approach; but from this remove, I don't see the need as yet...
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I'm creating a form when I submit I want to insert the posted datas in different tables in a defined order what is the best way to achieve this : 1 - insert a customer if he doesn't exists 2 - insert customer's enterprise if it does'nt exists 3 - insert the relation if customer does'nt exists 4 - insert the customer's reservation on a course
Thank you
@Eloïse Yes you would. The assignment would look something like this
$modelOne = ModelOne::create([
'name' => $validData['name']
]);
$modelTwo = ModelTwo::create([
'address' => $validData['address']
);
Please or to participate in this conversation.