belongsTo('App\SpUserTemplate', 'sp_user_template_id'); } public function site_config() { return $this->hasOne('App\SiteConfig'); } public function getSiteConfigDefaultOtherAttribute() { if (isset($this->site_config->other)) { return $this->site_config->other; } else { return \App\SiteConfig::whereNull('other')->first()->other; } } }