public function save(array $options = array()) { $user = parent::save($options); if (!empty($this->_profile)) { if (!$this->profile) { $profiles = $this->_profile; $profiles['user_id'] = $this->getKey(); \ProfileModel::create($profiles); } else { foreach ($this->_profile as $key => $val) { $this->profile->{$key} = $val; } $this->profile->save(); } $this->_profile = array(); } return $user; }