mirror of
https://github.com/flarum/framework.git
synced 2025-05-13 17:52:40 +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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static $permissions;
|
static $permissions = [];
|
||||||
|
|
||||||
if (!$permissions) {
|
if (! isset($permissions[$this->id])) {
|
||||||
$permissions = $this->permissions()->get();
|
$permissions[$this->id] = $this->permissions()->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (bool) $permissions->contains('permission', $permission);
|
return (bool) $permissions[$this->id]->contains('permission', $permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUnreadNotificationsCount()
|
public function getUnreadNotificationsCount()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user