public function __call($method, $parameters) { $class_name = class_basename($this); #i: Convert array to dot notation $config = implode('.', ['relations', $class_name, $method]); #i: Relation method resolver if (Config::has($config)) { $function = Config::get($config); return $function($this); } #i: No relation found, return the call to parent (Eloquent) to handle it. return parent::__call($method, $parameters); }