Alex
Alex

Reputation: 29

whereNotIn removes all values in the laravel model table

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()?

Upvotes: 0

Views: 420

Answers (1)

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111829

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.

Upvotes: 1

Related Questions