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

laravel, mysql, php

Solution

You can get the current user's id with `auth()->id()`. Then pass that to the query:

$users = User::where('id', '!=', auth()->id())->get();

Problem

I am doing: ``` User::all(); ``` 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, ``` User::where('id','!=',$currentUser->id)->get(); ``` Thanks in advance!

Original source