Is there a way in Laravel to bulk-insert multiple records and get Eloquent models returned? #57525
Replies: 3 comments 2 replies
-
|
The mass insert will not return the pks so that you can retrieve them by pk afterwards. |
Beta Was this translation helpful? Give feedback.
-
|
A couple of solutions from ChatGPT. While I don't have a need for this solution yet, I will in one of my next major App Enhancements. https://chatgpt.com/share/69010a68-9b4c-8007-9f12-e329b195dd45 |
Beta Was this translation helpful? Give feedback.
-
|
Hi I understood your question. if you want to insert multiple records with one request(one time).
Thank you |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I have a scenario where I need to insert multiple records at once.
I want to achieve all three:
One approach I thought of:
This works, but feels hardcoded, and I wonder if there’s a better or built-in Laravel way in Eloquent to do this. Or can be added in the future...
Beta Was this translation helpful? Give feedback.
All reactions