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

后端 未结 4 1854
无人共我
无人共我 2021-01-31 15:44

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

4条回答
  •  滥情空心
    2021-01-31 16:22

    If you are using the Auth helper, use this.

    User::where('id', '!=', Auth::user()->id)->get();
    

提交回复
热议问题