Reputation: 131
I have a table users in database
id, name, users_type
there are multiple types of users_type like Admin, Sub Admin, Unsigned, Normal User
I want to get All Types of users_type But Not Admin user.
Upvotes: 0
Views: 270
Reputation: 8307
If you are using eloquent Model then
$users = User::where('users_type', '!=', 'Admin')->get();
Using Query Builder
$users = DB::table('users')->where('users_type', '!=', 'Admin')->get();
check this for query builder https://laravel.com/docs/5.6/queries and for Eloquent you can look this https://laravel.com/docs/5.6/eloquent
Upvotes: 1
Reputation: 2328
$users = User::where('users_type','<>','Admin')->get();
You want to get result for equals to then no need add =
If you want to get only one user then use first()
insted of get()
Upvotes: 0