Setting.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\store\model\h5;
  13. use think\facade\Cache;
  14. use app\common\model\h5\Setting as SettingModel;
  15. /**
  16. * H5设置模型
  17. * Class Setting
  18. * @package app\store\model\wxapp
  19. */
  20. class Setting extends SettingModel
  21. {
  22. /**
  23. * 设置项描述
  24. * @var array
  25. */
  26. private $describe = [
  27. 'basic' => '基础设置',
  28. ];
  29. /**
  30. * 更新系统设置
  31. * @param string $key
  32. * @param array $values
  33. * @return bool
  34. */
  35. public function edit(string $key, array $values): bool
  36. {
  37. $model = self::detail($key) ?: $this;
  38. // 删除系统设置缓存
  39. Cache::delete('h5_setting_' . self::$storeId);
  40. return $model->save([
  41. 'key' => $key,
  42. 'describe' => $this->describe[$key],
  43. 'values' => $values,
  44. 'update_time' => time(),
  45. 'store_id' => self::$storeId,
  46. ]) !== false;
  47. }
  48. }