/** * Create inspection for model field. * * @param string $field * @return FieldInspection */ private function inspectField($field) { $filters = $this->reflection->getSetters() + $this->reflection->getAccessors(); $fillable = true; if ($this->reflection->getSecured() === '*' || in_array($field, $this->reflection->getSecured())) { $fillable = false; } if ($this->reflection->getFillable() != []) { $fillable = in_array($field, $this->reflection->getFillable()); } return new FieldInspection($this->inspector, $field, $this->reflection->getFields()[$field], $fillable, in_array($field, $this->reflection->getHidden()), isset($filters[$field]), array_key_exists($field, $this->reflection->getValidates())); }
/** * Generate set of fields for given entity, only fillable fields will be added. * * @param ReflectionEntity $entity */ public function followEntity(ReflectionEntity $entity) { foreach ($entity->getFillable() as $field) { $type = $entity->getFields()[$field]; //Let's use data by default $this->addField($field, $type, 'data'); if (!empty($entity->getValidates()[$field])) { //Let's use validation declared in entity if ($entity->getValidates()[$field] != ['notEmpty']) { //We are only going to use default entity validation if $this->validates[$field] = $entity->getValidates()[$field]; } } } }