Priyanka Priyanka - 1 year ago 163
MySQL Question

Get all the users except current logged in user in laravel eloquent

I am doing:


to get all the users from users table. I want to select all the users except current logged in user. How should I do that? something like,


Thanks in advance!

Answer Source

You can get the current user's id with Auth::id(). Then pass that to the query:

$users = User::where('id', '!=', Auth::id())->get();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download