public function getAttribute($key, $subKey = null) { if (is_null($subKey) && $this->hasAttribute($key)) { return $this->attributes[$key]; } elseif ($this->hasAttribute($key, $subKey)) { return $this->attributes[$key][$subKey]; } }