/** * Adds a permission to the merged permissions Collection. * Override logic is handled from outside to enable strict or standard permissions. * * @param Permission $permission * @param bool $override */ protected function add(Permission $permission, $override = true) { if ($override || !$this->permissions->containsKey($permission->getName())) { $this->permissions->set($permission->getName(), $permission); } }
/** * @param Permission|string $permission * * @return Permission|null */ protected function getPermission($permission) { $name = $permission instanceof Permission ? $permission->getName() : $permission; return $this->permissions->filter(function (Permission $current) use($name) { return $current->getName() == $name; })->first(); }