Setting.php 931 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\store\model\bargain;
  3. use think\Cache;
  4. use app\common\model\bargain\Setting as SettingModel;
  5. /**
  6. * 砍价活动设置模型
  7. * Class Setting
  8. * @package app\store\model\bargain
  9. */
  10. class Setting extends SettingModel
  11. {
  12. /**
  13. * 设置项描述
  14. * @var array
  15. */
  16. private $describe = [
  17. 'basic' => '基础设置',
  18. ];
  19. /**
  20. * 更新系统设置
  21. * @param $key
  22. * @param $values
  23. * @return bool
  24. * @throws \think\exception\DbException
  25. */
  26. public function edit($key, $values)
  27. {
  28. $model = self::detail($key) ?: $this;
  29. // 删除系统设置缓存
  30. Cache::rm('bargain_setting_' . self::$wxapp_id);
  31. return $model->save([
  32. 'key' => $key,
  33. 'describe' => $this->describe[$key],
  34. 'values' => $values,
  35. 'wxapp_id' => self::$wxapp_id,
  36. ]) !== false;
  37. }
  38. }