mirror of
https://github.com/flarum/framework.git
synced 2025-01-21 13:17:30 +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;
|
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()
|
public function getUnreadNotificationsCount()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user