You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to cache some models, such as "category" "user", how to work with cache?
The package GeneaLabs/laravel-model-caching just can't work with laravel-query-builder, even though use a custom builder, I got a error:
"message": "Property [localMacros] does not exist on the Eloquent builder instance.",
"exception": "Exception"
<?php
namespace App\Http\Queries;
use App\Models\Category;
use GeneaLabs\LaravelModelCaching\Traits\Buildable;
use GeneaLabs\LaravelModelCaching\Traits\BuilderCaching;
use GeneaLabs\LaravelModelCaching\Traits\Caching;
use Illuminate\Support\Facades\Cache;
use Spatie\QueryBuilder\QueryBuilder;
use Spatie\QueryBuilder\AllowedFilter;
class CategoryQuery extends QueryBuilder
{
use Buildable, BuilderCaching, Caching;
public function __construct()
{
parent::__construct(Category::query());
$this->allowedFields(['id', 'parent_id', 'title', 'course.id', 'course.title'])
->allowedFilters([
AllowedFilter::exact('id'),
AllowedFilter::exact('parent_id'),
AllowedFilter::exact('level'),
'title',
])
->defaultSort('sort_order')
->allowedSorts('sort_order');
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I want to cache some models, such as "category" "user", how to work with cache?
The package
GeneaLabs/laravel-model-caching
just can't work with laravel-query-builder, even though use a custom builder, I got a error:Beta Was this translation helpful? Give feedback.
All reactions