Replies: 1 comment
-
|
The cache stores all permissions and their role relationships — basically a snapshot of Why you're still seeing queries: When you call So what happens:
The cache prevents querying To minimize queries: // Eager load when fetching users
$user = User::with(['roles', 'permissions'])->find($id);
// Or load manually once
$user->load('roles', 'permissions');
// Then subsequent can() calls won't hit DB
$user->can('edit articles'); // no query
$user->can('delete articles'); // still no querytl;dr: cache = permission definitions, not user assignments. Eager load user relationships to avoid repeated queries. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi . can anyone explain what is cached in this repo?
because when I do a
$user->can('edit articles');
it querys the database.. so I dont understand what is cached.
thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions