调用未定义的方法 Illuminate\Database\Query\Builder::except()

Call to undefined method Illuminate\Database\Query\Builder::except()

我想获取不包括已登录用户的用户数。但是 运行 查询时出现此错误,我缺少什么?

Call to undefined method Illuminate\Database\Query\Builder::except()

    $user = Auth::user()->id;
    $tests = $this->user->where('referrer', $user)
                  ->except($user)
                  ->orderBy('id')
                  ->take(2)
                   ->get();


    // $this->user was already injected in the constructor

尝试使用 whereNotIn 而不是 except(),因为我认为 except() 不是查询生成器的方法或已被弃用。

$user = Auth::user()->id;

$tests = $this->user->where('referrer', $user)
              ->whereNotIn('id', [$user])
              ->orderBy('id')
              ->take(2)
               ->get();

https://laravel.com/docs/5.4/queries#where-clauses