/** * @param Permission $role */ public function addPermission(Permission $role) { $role->addGroup($this); if (!$this->permissions->contains($role)) { $this->permissions->add($role); } }
/** * {@inheritdoc} */ public function updatePermission($permission, $allow = true, $create = false) { if ($existing = $this->getPermission($permission)) { if ($allow && !$existing->isAllowed()) { $existing->allow(); } elseif (!$allow && $existing->isAllowed()) { $existing->deny(); } } elseif ($create) { $this->permissions->add($this->createPermission($permission, $allow)); } $this->refreshPermissionsInstance(); return $this; }