97476/get-all-the-users-except-current-logged-user-laravel-eloquent
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();
Hello @kartik,
You can get the current user's id with auth()->id(). Then pass that to the query:
$users = User::where('id', '!=', auth()->id())->get();
Hope it helps!!
Thank you!!
Hey, We can get the user's IP address ...READ MORE
Hey @kartik, yes we can keep track of ...READ MORE
Hello @kartik, Here is the way I do ...READ MORE
Hello @kartik, in Laravel's inbuilt auth system, the ...READ MORE
Hey @kartik, First you have to go to ...READ MORE
Named route is used to give specific ...READ MORE
Hello, This is simple you just need to ...READ MORE
Hey @kartik, Named routing is another amazing feature of ...READ MORE
Hello @kartik, You can use: Request::url() to obtain the current ...READ MORE
Hey, In order to identify the type of ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.