vedmant
466
4
Laravel

The best way to cache Laravel Policies

Posted 3 years ago by vedmant

Hi, I have situation when I have many to many relations between users and groups and pivot table has type column that can have either 'admin' or 'participant' value. The problem here is that I need to pull pivot table record on every policy check to get this type field. And when I use @can() directive in templates it generates tons of the same queries. Is there a good simple way to add caching to Laravel Policies? So it will run actual policy method only once.

Please sign in or create an account to participate in this conversation.