laravel 紧凑():未定义的变量:运算符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/56726263/
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
compact(): Undefined variable: operator
提问by Kareimovich
I'm getting the following error
我收到以下错误
(1/1) ErrorException
compact(): Undefined variable: operator
This is my line of code
这是我的代码行
$postsCat = Post::whereHas('Cat', function($query) use ($sreachWord) {
return $query->whereRaw('name REGEXP"'.sql_text_to_regx($sreachWord).'"');
})->orderBy('top','desc')
->orderBy('updated_at','desc')
->paginate(30);
Why is this happening? Is it because of my PHP version (7.3) or something else?
为什么会这样?是因为我的 PHP 版本 (7.3) 还是其他原因?
回答by eaststrong
Please refer to this https://github.com/laravel/framework/issues/26936
请参考这个 https://github.com/laravel/framework/issues/26936
The version of Laravel would need to be updated.
Laravel 的版本需要更新。
回答by Hasanur Rahman Himel
Go to your project in vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php
转到 vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php 中的项目
In line number 1337, you can found below code inside the addWhereExistsQuery method
在第 1337 行,您可以在 addWhereExistsQuery 方法中找到以下代码
$this->wheres[] = compact('type', 'operator', 'query', 'boolean');
$this->wheres[] = compact('type', 'operator', 'query', 'boolean');
you just remove the 'operator' paramiter
您只需删除“操作员”参数
and I hope it will work fine
我希望它能正常工作