You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running a whereHas method off a hasMany relation blows up with: ErrorException: compact(): Undefined variable: operator in file /var/www/testproject/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php on line 1243
Steps To Reproduce:
Define a hasMany relation on a model. Ensure that the child model on the relation has at least one relation other than to the parent.
Query the parent's hasMany relation - here's how I tripped over it:
$result = $parentModel->manyRelation()->whereHas('childOtherRelation', function ($query) use ($value) {
$query->where('name', '=', $value);
})->firstOrFail();
Execute that query under PHP 7.3. I tripped over this by running a test case.
Bombs out with above error.
Looking at the chunk of code (addWhereExistsQuery in Query/Builder.php), I'm not seeing where $operator ever got defined.