public function __get($key) { $value = Parent::__get($key); if ($value === null) { // No lowest-level setting? if ($this->optionable_type == 'App\\Models\\SiteComponents\\Location') { // Load the default settings $className = class_name($this); return $className::doesntHave('optionable'); } else { if ($this->optionable_type == 'App\\User') { // Load the Location settings $camelClass = camel_case(class_name($this)); return $this->optionable->location()->first()->{$camelClass}->{$key}; } else { // Load the User settings $camelClass = camel_case(class_name($this)); return $this->optionable->user()->first()->{$camelClass}->{$key}; } } } return $value; }