Bulk/Batch Update/create and return IDs #41107
Unanswered
DemonContractLabs
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
While developing applications using We always face an issue where we want to create or update multiple records and have id return. General what we have to do is use loop or a callback.
So I had an idea what if we have a function which can do this for us.
Example :
If i wanted to updated multiple records from given set of ids and I do not know if that record still exists or not.
$ids = [ 1, 7 ,13 ,123 ];
Post::whereIn('id',$ids)
->update(['"author_id' => 1]);
Or
Flight::where('active', 1)
->where('destination', 'San Diego')
->update(['delayed' => 1]);
In above examples
What if we had function
$query->updateGetIds();
Or
$ query->createGetIds();
Notes : ids of affected rows.
I don't know the idea my not be great but can be useful in every day coding.
Beta Was this translation helpful? Give feedback.
All reactions