BookStack\Entity::permissions PHP Метод

permissions() публичный Метод

Get this entities restrictions.
public permissions ( )
    public function permissions()
    {
        return $this->morphMany(EntityPermission::class, 'restrictable');
    }

Usage Example

Пример #1
0
 /**
  * Manually set some permissions on an entity.
  * @param \BookStack\Entity $entity
  * @param $actions
  */
 protected function setEntityRestrictions(\BookStack\Entity $entity, $actions)
 {
     $entity->restricted = true;
     $entity->permissions()->delete();
     $role = $this->user->roles->first();
     $viewerRole = $this->viewer->roles->first();
     foreach ($actions as $action) {
         $entity->permissions()->create(['role_id' => $role->id, 'action' => strtolower($action)]);
         $entity->permissions()->create(['role_id' => $viewerRole->id, 'action' => strtolower($action)]);
     }
     $entity->save();
     $entity->load('permissions');
     $this->restrictionService->buildJointPermissionsForEntity($entity);
     $entity->load('jointPermissions');
 }
All Usage Examples Of BookStack\Entity::permissions