Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using whereHas with BelongsToMany #120

Open
fan711 opened this issue May 1, 2023 · 1 comment
Open

Error when using whereHas with BelongsToMany #120

fan711 opened this issue May 1, 2023 · 1 comment

Comments

@fan711
Copy link

fan711 commented May 1, 2023

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);
    }
@abishekrsrikaanth
Copy link

This is not specific to BelongsToMany, but also BelongsTo relationship.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants