Closed antoscarface closed 2 years ago
It doesn't work even if I add the cache trait in the pivot table class:
class ModelABPivot extends Pivot {
use QueryCacheable;
protected static bool $flushCacheOnUpdate = true;
}
This issue has been automatically closed because it has not had any recent activity. 😨
Hi,
I'm using your library to cache entities with Eloquent and I also read this in order to invalidate cache also with ManyToMany relationships, using pivot tables.
I installed
chelout/laravel-relationship-events
and added the traits, it works in one direction and not in the other. I explain with an example:Given these models:
When I run
$modelA->modelBs()->attach($modelB)
:$modelB->modelAs()
returns the$modelA
attached$modelA->modelBs()
does notI do need
ModelA::flushCache()
to make it work.Same thing vice-versa when using
detach
.What's wrong with what I did? Could you please help me?