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
Argument 1 passed to App\Client::App\{closure}() must be an instance of Illuminate\Database\Eloquent\Builder, instance of Staudenmeir\LaravelCte\Query\Builder given
#34
Closed
Healyhatman opened this issue
Dec 1, 2021
· 1 comment
Any closure that you could type-hint with Eloquent\Builder before installing the package, still works the same.
Methods like whereIn() pass a base query builder (Illuminate\Database\Query\Builder) into the closure, not an Eloquent builder. The package extends the query base builder with Staudenmeir\LaravelCte\Query\Builder globally and that's now passed into the closure. Because it's a subclass, a base query builder type-hint still works.
You can pass an Eloquent builder to whereIn(), but you don't get one in the closure:
Often, for reasons I don't understand, type-hinting a closure as Eloquent/Builder fails because it's apparently been passed a CteBuilder instead.
Why does this happen when as far as I can tell the particular scope isn't using any CTE functions?
For example, this:
\App\Client::whereIn('SYSID', function($q) { dd($q); })->first();
tells me that $q is a CteBuilder.
Client doesn't use QueriesExpressions, extends normal Model class. I don't know why it would be insisting on using the CTE builder in that function.
The text was updated successfully, but these errors were encountered: