Get or create a field.

@param  string $key
@param  string|array|null $value
@param  string|array|null $description
@return \Indigoram89\Fields\Field
195766
public function field(string $key, $value = null, $description = null)
    {
        if ( ! $field = $this->fields->where('key', $key)->first()) {
            $this->fields->push(
                $field = $this->fields()->firstOrNew(compact('key'))
            );
        }

        $field->setDefaultValue($value);
        $field->setDefaultDescription($description);

        $field->save();

        return $field;
    }
605924
protected function getFieldValue($value, FieldDefinition $fieldDefinition, $contentTypeIdentifier, array $context = array())
    {
        $fieldTypeIdentifier = $fieldDefinition->fieldTypeIdentifier;

        if (is_array($value) || $this->fieldHandlerManager->managesField($fieldTypeIdentifier, $contentTypeIdentifier)) {
            // since we now allow refs to be arrays, let's attempt a 1st pass at resolving them here instead of every single fieldHandler...
            if (is_string($value) && $this->fieldHandlerManager->doPreResolveStringReferences($fieldTypeIdentifier, $contentTypeIdentifier)) {
                $value = $this->referenceResolver->resolveReference($value);
            }
            // inject info about the current content type and field into the context
            $context['contentTypeIdentifier'] = $contentTypeIdentifier;
            $context['fieldIdentifier'] = $fieldDefinition->identifier;
            return $this->fieldHandlerManager->hashToFieldValue($fieldTypeIdentifier, $contentTypeIdentifier, $value, $context);
        }

        return $this->getSingleFieldValue($value, $fieldDefinition, $contentTypeIdentifier, $context);
    }
841975
public function create(string $tag = 'div', $value = null, array $attributes = []): Htmlable
    {
        if (\is_array($value)) {
            $attributes = $value;
            $value = null;
        }

        $content = '<'.$tag.$this->attributes($attributes).'>';

        if (! \is_null($value)) {
            $content .= $this->entities($value).'</'.$tag.'>';
        }

        return $this->toHtmlString($content);
    }
1250497
public function addField($key, $value)
    {
        $fields       = $this->_queryBuilder->getFields() ? $this->_queryBuilder->getFields() : array();
        $fields[$key] = $value;
        $this->setFields($fields);
        return $this;
    }
581861
public function attribute($key, $value = null) {
        if (is_array($key)) {
            $this->_attributes = array_replace($this->_attributes, $key);
        } else {
            $this->_attributes[$key] = $value;
        }

        return $this;
    }
1189649
public function append( $key, $value ) {

		if ( isset( $this->redactedFields[$key] ) ) {
			return null;
		}

		if ( !$this->has( $key ) ) {
			$this->recordFields[$key] = array();
		}

		if ( is_array( $this->recordFields[$key] ) ) {
			$this->recordFields[$key][] = $value;
		} else{
			$this->recordFields[$key] = $this->recordFields[$key] . $value;
		}
	}
601236
public function hiddenField($key, $value=null, array $attr=[]){
		$this->context->hiddenField($key, $value, $attr);
	}
175032
public function get($key, $value = null)
    {
        return $this->postBag->key($key, $value, true);
    }
854619
public function setDescription($description) {
		if (is_array($description) && empty($description)) {
			$this->description = new \stdClass;
		} else {
			$this->description = $description;
		}

		return $this;
	}
467992
public function description($description = null)
    {
        if ($description !== null) {
            $this->_description = $description;
        }
        return $this->_description;
    }
536168
public function setDescription($description)
    {
        if (!$this->setHeaderFieldModel('Content-Description', $description)) {
            $this->headers->addTextHeader('Content-Description', $description);
        }

        return $this;
    }
164169
public function get($key, $value = null)
    {
        return $this->queryBag->key($key, $value, true);
    }
193712
private function getCreatedAt(Description $description)
    {
        $createdAt = $description->getOptionalProperty('createdAt');

        return ($createdAt !== null) ? (new \DateTimeImmutable())->setTimestamp($createdAt) : null;
    }
698147
public function set($key, $value = null)
    {
        $data = is_array($key) ? $key : [$key => $value];
        $obj = self::instance();
        $obj->fill($data);
        return $obj->save();
    }
960481
public function description(string $value = null)
    {
        if (null === $value) {
            return $this->description;
        }
        $this->description = $value;
        return $this;
    }
336660
public function setDescription($description = null) {

        if ( empty($description) ) $this->description = null;

        else if ( !is_string($description) ) throw new InvalidArgumentException("Invalid RpcMethod description");

        else $this->description = $description;

        return $this;

    }
974526
public function get(string $key, $value = null)
    {
        if ($this->__isset($key)) {
            $value = $this->options[$key];
        }

        return $value;
    }