mirror of
https://github.com/flarum/framework.git
synced 2025-05-14 02:02:39 +08:00
Cache permissions per user ID
This commit is contained in:
parent
a7e02ca890
commit
f2888ee65f
@ -312,13 +312,13 @@ class User extends Model
|
||||
return true;
|
||||
}
|
||||
|
||||
static $permissions;
|
||||
static $permissions = [];
|
||||
|
||||
if (!$permissions) {
|
||||
$permissions = $this->permissions()->get();
|
||||
if (! isset($permissions[$this->id])) {
|
||||
$permissions[$this->id] = $this->permissions()->get();
|
||||
}
|
||||
|
||||
return (bool) $permissions->contains('permission', $permission);
|
||||
return (bool) $permissions[$this->id]->contains('permission', $permission);
|
||||
}
|
||||
|
||||
public function getUnreadNotificationsCount()
|
||||
|
Loading…
x
Reference in New Issue
Block a user