I have 4 components. The main component is product. And 3 childs components : categories, images, tags …
I want to get product id before save my product . For the other 3 components .
Get the id product before save
you can assign you model in variable and get the instance after saving you product
$product = Product::create([...]);
$product->id;
All my components are separated . Not in same component.
So, You can use event listeners.
Take a look here in the docs:
let me know if you have any questions.
1 Like