Doesn't work with Spatie's Laravel QueryBuilder #487
Replies: 7 comments
-
@backstageel Thanks for submitting your issue. This package will not work with third-party query builders, only with Laravel's query builder. Sorry. |
Beta Was this translation helpful? Give feedback.
-
Actually, i got this Working... It was as simple as creating a custom builder class that extends Spatie's QueryBuilder and apply the traits from this package on it: namespace App\Builders;
use GeneaLabs\LaravelModelCaching\Traits\Buildable;
use GeneaLabs\LaravelModelCaching\Traits\BuilderCaching;
use GeneaLabs\LaravelModelCaching\Traits\Caching;
use Spatie\QueryBuilder\QueryBuilder;
class CustomBuilder extends QueryBuilder
{
use Buildable;
use BuilderCaching;
use Caching;
} |
Beta Was this translation helpful? Give feedback.
-
I'll add this to the documentation, thanks! |
Beta Was this translation helpful? Give feedback.
-
@mikebronner This doesn't seem to be added to the documentation? :) @backstageel Does it still work for you? |
Beta Was this translation helpful? Give feedback.
-
I think I removed it again, because I started work on developing an internal solution that wouldn't require more work. Unfortunately I have not been able to complete that at this time due to life circumstances changing A LOT this year. |
Beta Was this translation helpful? Give feedback.
-
"a custom builder class" not work for me
|
Beta Was this translation helpful? Give feedback.
-
any update? |
Beta Was this translation helpful? Give feedback.
-
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
But this work:
Stack Trace
No stack trace, because no error is generated. Just no data is cached
Environment
Beta Was this translation helpful? Give feedback.
All reactions