如何在Laravel 4中查询除一个以外的所有内容?

ior*_*ori 1 php mysql database blade laravel-4

CONTROLLER

public function index() {
    $users = User::all(); // Is there a way to chain it with the except method or sth like that
    return View::make('distributors.index')->with('users',$users);
}
Run Code Online (Sandbox Code Playgroud)

目标

我想查询我的所有用户表,但只有一个.

我想列出我的客户的所有用户,但我想隐藏自己.

我怎么做 ?我是以正确的方式接近它吗?

随意给我任何改进的建议.

Sud*_*oti 6

如果您的意思是除了当前登录的用户,那么执行:

$users = User::where('id', '!=', Auth::id())->get();
Run Code Online (Sandbox Code Playgroud)