Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How would I do the opposite of ->where('array_field', 'all', ['item']) #2114

Answered by fidan-mkdir
fidan-mkdir asked this question in Q&A
Discussion options

I have the need to find all users that do not have a certain permission. What I would do when I want to find all users with some permissions is:

$users = User::where('permissions', 'all', ['my permission', 'other permission'])->get();

But if I want to find specific users that do not have the 'admin admin' permission, I have no idea how to do it.

You must be logged in to vote

Wow, was it as simple as $users = User::where('permissions','!=, 'admin admin')->get(); or am I missing something, I've wasted more than an hour to try this..

Replies: 1 comment 1 reply

Comment options

Wow, was it as simple as $users = User::where('permissions','!=, 'admin admin')->get(); or am I missing something, I've wasted more than an hour to try this..

You must be logged in to vote
1 reply
Comment options

Yes, it definitely was that simple, in case anyone else is wondering the same.

Answer selected by fidan-mkdir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /