Get a plain attribute (not a relationship).
public getAttributeValue ( string $key ) : mixed | ||
$key | string | |
Résultat | mixed |
public function getAttributeValue($key) { $value = parent::getAttributeValue($key); if (in_array($key, array_keys($this->postgresifyTypes))) { if (!is_null($value)) { return PostgresifyTypeTransformer::transform($key, $value, $this->postgresifyTypes[$key]); } } return $value; }
/** * Get a plain attribute (not a relationship). * @param string $key * @return mixed */ public function getAttributeValue($key) { $attr = parent::getAttributeValue($key); /* * Return valid json (boolean, array) if valid, otherwise * jsonable fields will return a string for invalid data. */ if (in_array($key, $this->jsonable) && !empty($attr)) { $_attr = json_decode($attr, true); if (json_last_error() === JSON_ERROR_NONE) { $attr = $_attr; } } return $attr; }
/** * Get a plain attribute (not a relationship). * * @param string $key * @param WidgetInterface $widget * * @return mixed */ public function getWidgetValue($key, WidgetInterface $widget) { $value = parent::getAttributeValue($key); if (!is_null($field = $this->getFieldsCollection()->getByKey($key))) { $value = $field->onGetWidgetValue($this, $widget, $value); } return $value; }
/** * Get a plain attribute (not a relationship). * @param string $key * @return mixed */ protected function getAttributeValue($key) { $attr = parent::getAttributeValue($key); // Handle jsonable if (in_array($key, $this->jsonable) && !empty($attr)) { $attr = json_decode($attr, true); } return $attr; }
/** * Get a plain attribute (not a relationship). * @param string $key * @return mixed */ public function getAttributeValue($key) { /* * Before Event */ if (($attr = $this->fireEvent('model.beforeGetAttribute', [$key], true)) !== null) { return $attr; } $attr = parent::getAttributeValue($key); /* * Return valid json (boolean, array) if valid, otherwise * jsonable fields will return a string for invalid data. */ if ($this->isJsonable($key) && !empty($attr)) { $_attr = json_decode($attr, true); if (json_last_error() === JSON_ERROR_NONE) { $attr = $_attr; } } /* * After Event */ if (($_attr = $this->fireEvent('model.getAttribute', [$key, $attr], true)) !== null) { return $_attr; } return $attr; }
public function getAttributeValue($key) { if (!$key) { return null; } return parent::getAttributeValue($key); }
/** * Get a plain attribute (not a relationship). * * @param string $key * @return mixed */ public function getAttributeValue($key) { $value = parent::getAttributeValue($key); if ($value instanceof Carbon && $this->timestamp_get_with_user_timezone) { $value->setTimezone($this->getAuthUserDateTimezone()); } return $value; }