Php Laravel 5.6:ErrorException:compact():未定义变量:运算符

Php Laravel 5.6:ErrorException:compact():未定义变量:运算符,php,laravel,upgrade,laravel-5.6,Php,Laravel,Upgrade,Laravel 5.6,我正在将我的laravel从5.5升级到5.6。在运行测试时,我得到以下错误: $query = TransportOrder::with('orderNumber'); $query->whereHas('orderNumber', function ($q) use ($orderNumber) { $q->where('order_number', '=', $orderNumber); }); return $query->first(); Error

我正在将我的
laravel
5.5
升级到
5.6
。在运行测试时,我得到以下错误:

$query = TransportOrder::with('orderNumber');

$query->whereHas('orderNumber', function ($q) use ($orderNumber) {
      $q->where('order_number', '=', $orderNumber);
});

return $query->first();
ErrorException:compact():未定义变量:运算符

现在这里有一个解决方案,但我遵循这个解决方案,仍然面临这个错误。早些时候我从
5.4
升级到
5.6
,然后在看到上述问题中提到的解决方案后,我从
5.4
升级到
5.5
,现在尝试从
5.5
升级到
5.6

下面是导致此错误的一小段代码:

$query = TransportOrder::with('orderNumber');

$query->whereHas('orderNumber', function ($q) use ($orderNumber) {
      $q->where('order_number', '=', $orderNumber);
});

return $query->first();
导致此问题的是
whereHas
。那么,除了
中的
之外,还有其他的解决方案吗

我的php版本如下:

PHP 7.3.23-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Oct  6 2020 11:36:27) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.23, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.23-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    with blackfire v1.24.2~linux-x64-non_zts73, https://blackfire.io, by Blackfire
编辑:

compact()
用于
vendor
class
Builder

public function addWhereExistsQuery(self $query, $boolean = 'and', $not = false)
    {
        $type = $not ? 'NotExists' : 'Exists';

        $this->wheres[] = compact('type', 'operator', 'query', 'boolean');

        $this->addBinding($query->getBindings(), 'where');

        return $this;
    }

事实证明,将laravel升级到6.5.40确实起到了作用,因为在早期版本中没有解决上述问题。

我的代码中没有使用compact,而是在供应商文件中@KamleshPaul我已经更新了这个问题。
$this->wheres[]=compact('type','operator','query','boolean')此行导致错误,它希望有变量try
$not=false
$operator=false
可能是您want@KamleshPaul这是供应商文件,我不想更改。请删除该库。