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;
    }
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;
    }
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 ; }
Get or create a field.

@param  string $key
@param  string|array|null $value
@param  string|array|null $description
@return \Indigoram89\Fields\Field
Get or create a field .