Strict Type throwing error for Nested Model filter
Created by: JituSSingh
When we have a query in this format for e.g.: filter[hhga.status]=1 , when setWithQuery method of HasQueryBuilder is looping through array $where , for nested model filter like the one in given example, will pass setQueryBuilderWhereStatement(Builder $query, string $key, $where) an instance of Illuminate\Database\Eloquent\Relations\HasOne , instead of Illuminate\Database\Eloquent\Builder type, and because the type differs for this use case it throws TypeError Exception with the message :
Phpsa\\LaravelApiController\\Http\\Api\\Controller::setQueryBuilderWhereStatement(): Argument #1 ($query) must be of type Illuminate\\Database\\Eloquent\\Builder, Illuminate\\Database\\Eloquent\\Relations\\HasOne given, called in /var/www/vendor/phpsa/laravel-api-controller/src/Http/Api/Contracts/HasQueryBuilder.php on line 60.
In v1.x same method was present in src/Contracts/Parser.php but the method signature was less strict like this setQueryBuilderWhereStatement($query, $key, $where): void most likely the strict typing is causing this issue.