Setting.php 623 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace app\admin\model\settings;
  3. use app\common\enum\settings\SettingEnum;
  4. use app\common\model\settings\Setting as SettingModel;
  5. class Setting extends SettingModel
  6. {
  7. /**
  8. * 新增
  9. */
  10. public function add($data)
  11. {
  12. $service = $this->where(['key' => SettingEnum::SYS_CONFIG])->find();
  13. if(!$service){
  14. $add['key'] = SettingEnum::SYS_CONFIG;
  15. $add['describe'] = '系统设置';
  16. $add['values'] = $data;
  17. return $this->save($add);
  18. }else{
  19. return $this->where(['key' => SettingEnum::SYS_CONFIG])->save(['values'=>json_encode($data)]);
  20. }
  21. }
  22. }