whereNotIn removes all values in the laravel model table

429 Views Asked by At
MyMode::whereNotIn('id', $someCollection->pluck('id')->toArray())->delete();

removes all values from the table. But I think it shoudt remove only items which are not present in $someCollection. How to remove items which are not in $someCollection->pluck('id')->toArray()?

1

There are 1 best solutions below

2
On

It should work without a problem. You should verify first what you have in $someCollection->pluck('id')->toArray() to make sure it doesn't return all/none rows from MyMode model.