Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

Hi mate,

I think you are looking for something like this:

$foo = MyModel::where('user_id', '=', $user_id)->whereNotIn( 'id', [1, 2, 7])->get();
Last updated 1 year ago.
0

It worked! Thank you so much!

Last updated 1 year ago.
0

HI,

The above query works fine . So far i am trying to get using the below query

Wrong Way :

User::orderby('username')->where('company', '=', $company_id and 'id' '!=' $user_id)->get();

gives sql error.

Correct one :

User::orderby('username')->where('company', '=', $company_id)->whereNotIn( 'id', [$user_id])->get();

Out put of query :

select * from `users` where `company` = 2 and `id` not in (4)

Thanks for your right syntax query

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

balintant balintant Joined 2 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.