mirror of
https://github.com/flarum/framework.git
synced 2025-01-20 03:42:44 +08:00
Cache user permissions between calls
This commit is contained in:
parent
9ac1f53244
commit
963078b375
|
@ -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