Illuminate\Database\Eloquent\Model::mutateAttribute PHP Method

mutateAttribute() protected method

Get the value of an attribute using its mutator.
protected mutateAttribute ( string $key, mixed $value ) : mixed
$key string
$value mixed
return mixed
    protected function mutateAttribute($key, $value)
    {
        return $this->{'get' . Str::studly($key) . 'Attribute'}($value);
    }

Usage Example

 /**
  * Get the value of an attribute using its mutator.
  *
  * @param  string $key
  * @param  mixed  $value
  *
  * @return mixed
  */
 protected function mutateAttribute($key, $value)
 {
     if ($this->hasField($key)) {
         return $this->getFields()->get($key)->onGetDocumentValue($this, $value);
     }
     return parent::mutateAttribute($key, $value);
 }
Model