/** * @param Entity $entity * @param $id * * @return \Kalnoy\Cruddy\Contracts\Field */ protected function resolveField(Entity $entity, $id) { $field = $entity->getFields()->get($id); if ($field === null) { throw new \RuntimeException("The field [{$entity->getId()}.{$id}] is not found."); } return $field; }
/** * @param string $action * @param Entity $entity * * @return bool */ public function isPermitted($action, Entity $entity) { $key = "{$entity->getId()}.{$action}"; return ($user = $this->sentry->getUser()) && $user->hasAccess($key); }
/** * {@inheritdoc} */ public function toArray() { return ['multiple' => $this->isMultiple(), 'reference' => $this->reference->getId()] + parent::toArray(); }