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

后端 未结 4 1844
无人共我
无人共我 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:45

    Use Auth;
    Use App\User;
    
    public function index()
    $id = Auth::id();
    $result = User::where('id', '!=', $id)->get();
    dd($result);
    

提交回复
热议问题