0

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.

1
  • have you tried doing sql directly to the database? just sql query. without eloquent or any. Commented Jun 22, 2018 at 4:24

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0
$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()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.