Skip to content

Commit dc76c94

Browse files
authored
Merge pull request #2316 from xiCO2k/refactor-permission-cache-query
Extract query to `getPermissionsWithRoles` method.
2 parents 6314c02 + 79ae998 commit dc76c94

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/PermissionRegistrar.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ public function getCacheStore(): Store
273273
return $this->cache->getStore();
274274
}
275275

276+
protected function getPermissionsWithRoles(): Collection
277+
{
278+
return $this->getPermissionClass()->select()->with('roles')->get();
279+
}
280+
276281
/**
277282
* Changes array keys with alias
278283
*
@@ -310,7 +315,7 @@ private function getSerializedPermissionsForCache()
310315
{
311316
$this->except = config('permission.cache.column_names_except', ['created_at', 'updated_at', 'deleted_at']);
312317

313-
$permissions = $this->getPermissionClass()->select()->with('roles')->get()
318+
$permissions = $this->getPermissionsWithRoles()
314319
->map(function ($permission) {
315320
if (! $this->alias) {
316321
$this->aliasModelFields($permission);

0 commit comments

Comments
 (0)