/** * @inheritdoc */ public function __get($name) { if ($name == 'super_admin') { /** * Replacement for old super_admin flag version */ return $this->isSystemAdmin(); } else { if ($name == 'profile') { /** * Ensure there is always a related Profile Model also when it's * not really exists yet. */ $profile = parent::__get('profile'); if (!$this->isRelationPopulated('profile') || $profile === null) { $profile = new Profile(); $profile->user_id = $this->id; $this->populateRelation('profile', $profile); } return $profile; } } return parent::__get($name); }
public function __get($name) { /** * Ensure there is always a related Profile Model also when it's * not really exists yet. */ if ($name == 'profile') { $profile = parent::__get('profile'); if (!$this->isRelationPopulated('profile') || $profile === null) { $profile = new Profile(); $profile->user_id = $this->id; $this->populateRelation('profile', $profile); } return $profile; } return parent::__get($name); }