Skip to content

Error when using whereHas with BelongsToMany #120

@fan711

Description

@fan711

When using whereHas in a query builder there is an error message:

   TYPE ERROR  Spiritix\LadaCache\Reflector::getTablesFromWhere(): Argument #1 ($queryBuilder) must be of type Spiritix\LadaCache\Database\QueryBuilder, Illuminate\Database\Query\Builder given, called in vendor/spiritix/lada-cache/src/Spiritix/LadaCache/Reflector.php on line 145 in vendor/psy/psysh/src/Exception/TypeErrorException.php on line 53.

Code:

Expert::whereHas('users', function ($query) {
    $query->whereNotNull('users.updated_at');
})->get();

Relationship from model 'Expert' to model 'User':

    public function users(): BelongsToMany
    {
        return $this->belongsToMany(User::class, 'user_expert')
            ->using(ExpertCategoryExpert::class);
    }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions