Setting.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\store\model\sharp;
  10. use think\Cache;
  11. use app\common\model\sharp\Setting as SettingModel;
  12. /**
  13. * 整点秒杀设置模型
  14. * Class Setting
  15. * @package app\store\model\sharp
  16. */
  17. class Setting extends SettingModel
  18. {
  19. /**
  20. * 设置项描述
  21. * @var array
  22. */
  23. private $describe = [
  24. 'basic' => '基础设置',
  25. ];
  26. /**
  27. * 更新系统设置
  28. * @param $key
  29. * @param $values
  30. * @return bool
  31. * @throws \think\exception\DbException
  32. */
  33. public function edit($key, $values)
  34. {
  35. $model = self::detail($key) ?: $this;
  36. // 删除系统设置缓存
  37. Cache::rm('sharp_setting_' . self::$wxapp_id);
  38. return $model->save([
  39. 'key' => $key,
  40. 'describe' => $this->describe[$key],
  41. 'values' => $values,
  42. 'wxapp_id' => self::$wxapp_id,
  43. ]) !== false;
  44. }
  45. }