getAttributeFromArray() protected method

Get an attribute from the $attributes array.
protected getAttributeFromArray ( string $key ) : mixed
$key string
return mixed
Example #1
0
 /**
  * Provides public access to get the raw attribute value from the model.
  * Used in areas where no mutations are required but performance is critical.
  * @param $key
  * @return mixed
  */
 public function getRawAttribute($key)
 {
     return parent::getAttributeFromArray($key);
 }
Example #2
0
 /**
  * Get an attribute from the $attributes array.
  *
  * @param  string  $key
  * @return mixed
  */
 protected function getAttributeFromArray($key)
 {
     // Support keys in dot notation.
     if (str_contains($key, '.')) {
         $attributes = array_dot($this->attributes);
         if (array_key_exists($key, $attributes)) {
             return $attributes[$key];
         }
     }
     return parent::getAttributeFromArray($key);
 }
 /**
  * Get an attribute from the $attributes array.
  *
  * @param  string  $key
  * @return mixed
  */
 protected function getAttributeFromArray($key)
 {
     $value = parent::getAttributeFromArray($key);
     if (in_array($key, $this->booleanFields)) {
         $value = boolval($value);
     }
     return $value;
 }