diff --git a/framework/core/src/Core/Users/User.php b/framework/core/src/Core/Users/User.php index 6b68ab8d5..dc062dabf 100755 --- a/framework/core/src/Core/Users/User.php +++ b/framework/core/src/Core/Users/User.php @@ -60,6 +60,13 @@ class User extends Model 'notification_read_time' ]; + /** + * An cache of permissions, and whether or not this user has them. + * + * @var array + */ + protected $hasPermission = []; + /** * The hasher with which to hash passwords. * @@ -319,7 +326,11 @@ class User extends Model $this->setRelation('permissions', $this->permissions()->get()); } - return (bool) $this->permissions->contains('permission', $permission); + if (! isset($this->hasPermissions[$permission])) { + $this->hasPermission[$permission] = (bool) $this->permissions->contains('permission', $permission); + } + + return $this->hasPermission[$permission]; } /**