Can i get only inserted data, but not an updated and inserted? #22
Answered
by
lapaliv
NikitaPoplavskiy
asked this question in
Q&A
-
Hi there! Your package looks like a something good solution for my case. I just need to get only inserted data after upserting without updated |
Beta Was this translation helpful? Give feedback.
Answered by
lapaliv
Mar 8, 2023
Replies: 1 comment
-
Hello @NikitaPoplavskiy. Yes, sure. You can get it. There are two ways how to do it. The first way: app(BulkUpsert::class)
->onCreated(function(Collection $collection) {
// Here you will get only inserted models
})
->upsert(/* ... */); The second way: app(BulkUpsert::class)
->onSaved(function(Collection $collection) {
$insertedRows = $collection->filter(
fn(Model $model) => $model->wasRecentlyCreated
);
})
->upsert(/* ... */); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
NikitaPoplavskiy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @NikitaPoplavskiy.
Yes, sure. You can get it. There are two ways how to do it.
The first way:
The second way: