Hey,
I want to cache my queries like getting all projects assigned to a user.
I use ->remember(360, 'user_projects')
There is a way (an event listener or something) to forget cache when one of the table update?
Right now i have something like:
public static function boot()
{
parent::boot();
static::creating(function($project)
{
Cache::forget('user_projects');
});
static::updating(function($project)
{
Cache::forget('user_projects');
});
}
But i don't find this way too clean.
Thanks
you can move your code into a Model Observer http://laravel.com/docs/eloquent#model-observers
zenry said:
you can move your code into a Model Observer http://laravel.com/docs/eloquent#model-observers
Where is the best way to declare User::observe(new UserObserver); ?
Tavicu said:
zenry said:
you can move your code into a Model Observer http://laravel.com/docs/eloquent#model-observers
Where is the best way to declare User::observe(new UserObserver); ?
ServiceProvider -> boot() method
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community