Skip to content

Doesn't work with Spatie's Laravel QueryBuilder #275

@backstageel

Description

@backstageel

Describe the bug
Seems Like this Package doesn't work when using Spatie's Laravel query builder to fetch the data (https://github.com/spatie/laravel-query-builder). I've checked that package and they don't override newEloquentBuilder() method, so all should work.

By not working i mean no cache data is returned and the query still hits the database.

Eloquent Query
This query don't work

$student = QueryBuilder::for(Student::class)
            ->join('entidades', 'entidades.id', '=', 'alunos.entidade_id')
            ->where('entidades.user_id', $user->id)
            ->first();

But this work:

$student = Student::join('entidades', 'entidades.id', '=', 'alunos.entidade_id')
            ->where('entidades.user_id', $user->id)
            ->first();

Stack Trace
No stack trace, because no error is generated. Just no data is cached

Environment

  • PHP: 7.3.6
  • OS: Ubuntu 19.04
  • Laravel: 5.8.29
  • Model Caching: 0.6.1
  • Spatie Laravel Query Builder: 1.17.5

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions