public function save() { if (!$this->setting->getIsNewRecord()) { $this->setting->svalue = Json::encode($this->getAttributes()); } else { $this->setting->skey = $this->getSettingKey(); $this->setting->svalue = Json::encode($this->getAttributes()); } return $this->setting->save(); }