public function value($default = null)
{
switch ($this->attribute->type) {
case Attribute::TYPE_DROPDOWN:
return is_null($this->option_value) ? null : (int) $this->option_value;
case Attribute::TYPE_CHECKBOX_LIST:
return is_null($this->option_value) ? null : (int) $this->option_value;
case Attribute::TYPE_CHECKBOX:
return (bool) $this->number_value;
case Attribute::TYPE_NUMBER:
return is_null($this->number_value) ? null : (double) $this->number_value;
case Attribute::TYPE_TEXT:
return $this->text_value;
case Attribute::TYPE_SHORT_TEXT:
return $this->string_value;
case Attribute::TYPE_FILE:
return $this->string_value;
default:
return $default;
}
}