mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 21:43:38 +08:00
Cache user permissions between calls
This commit is contained in:
parent
f6e6090131
commit
822feb2497
|
@ -311,9 +311,13 @@ class User extends Model
|
|||
return true;
|
||||
}
|
||||
|
||||
$count = $this->permissions()->where('permission', $permission)->count();
|
||||
static $permissions;
|
||||
|
||||
return (bool) $count;
|
||||
if (!$permissions) {
|
||||
$permissions = $this->permissions()->get();
|
||||
}
|
||||
|
||||
return (bool) $permissions->contains('permission', $permission);
|
||||
}
|
||||
|
||||
public function getUnreadNotificationsCount()
|
||||
|
|
Loading…
Reference in New Issue
Block a user