laravel Eloquent whereHasNot 缺失

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33266838/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:33:14  来源:igfitidea点击:

Eloquent whereHasNot is missing

laraveleloquent

提问by Marty Thomas

I need to access eloquent's whereHasNotmethod (added here:
https://github.com/laravel/framework/commit/8f0cb08d8ebd157cbfe9fdebb54d2b71b0afaabd)

我需要访问 eloquent 的whereHasNot方法(在此处添加:
https: //github.com/laravel/framework/commit/8f0cb08d8ebd157cbfe9fdebb54d2b71b0afaabd

I have laravel/framework (v5.1.20) installed via composer. However, the method does not exist in my /Illuminate/Database/Eloquent/Builder.phpfile.

我通过 composer 安装了 laravel/framework (v5.1.20)。但是,该方法在我的/Illuminate/Database/Eloquent/Builder.php文件中不存在。

Here is what I have in composer.json

这是我在 composer.json 中的内容

"laravel/framework": "5.1.*",

Am I missing somewhere here?

我错过了这里的某个地方吗?

If I'm not able to add this via composer, how can I extend Eloquent within my app to add this method?

如果我无法通过 Composer 添加此方法,如何在我的应用程序中扩展 Eloquent 以添加此方法?

Thanks!

谢谢!

回答by whoacowboy

It was renamed to whereDoesntHaveon Dec 17, 2014.

它于whereDoesntHave2014年12月17日更名为。

/**
 * Add a relationship count condition to the query with where clauses.
 *
 * @param  string  $relation
 * @param  \Closure|null  $callback
 * @return \Illuminate\Database\Eloquent\Builder|static
 */
public function whereDoesntHave($relation, Closure $callback = null)
{
    return $this->doesntHave($relation, 'and', $callback);
}