Mike Thrussell
Mike Thrussell

Reputation: 4525

laravel sql statement - how to add additional clause to where isnot - 'where' '!=' OR

I want to grab all users from a database, except 2.

I used to grab all except one with this code:

$users = User::where('name', '!=','name1')->get();

but I'm unsure how to add an additional name to this.

Many thanks,

Mike

Upvotes: 2

Views: 38

Answers (1)

Saromase
Saromase

Reputation: 467

You can use WhereNotIn

Documentation

$users = User::whereNotIn('name', ['name1', 'name2', 'name3'])->get();

Hope this help you.

Upvotes: 5

Related Questions