Replies: 1 comment
-
Because there's a database transaction around it. It will only be saved to the database when the transaction is commited. https://medium.com/@radicalloop/database-transactions-in-laravel-daa1b9751872#:~:text=%E2%80%9CTransactions%E2%80%9D%20gives%20us%20power%20to,very%20easy%20API%20for%20Transaction.&text=Here%20is%20a%20simple%20example%20showing%20how%20to%20use%20Transactions%20in%20Laravel. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am importing a CSV with OnEachRow and in the onRow function, I have the models getting inserted. But, I want to do something like this
[public function onRow(Row $row)
{
$data = $row->toArray();
}](url)
When I use breakpoint in the line $this->lastInsertedProduct = Product::create($data); I get the model in the debugger, but, the model is not inserted in the database. Is it not saving when the statement Product::create($data); is called ?
I want to get the last inserted model instance and do something with it ( update its relations data )
Any idea what is wrong here ?
Beta Was this translation helpful? Give feedback.
All reactions