ConfigObserver.php 618 B

12345678910111213141516171819202122
  1. <?php
  2. namespace App\Observers;
  3. use App\Components\Helpers;
  4. use App\Models\Config;
  5. use Cache;
  6. use Illuminate\Support\Arr;
  7. class ConfigObserver
  8. {
  9. public function updated(Config $config): void
  10. {
  11. // 更新系统参数缓存
  12. Cache::tags('sysConfig')->put($config->name, $config->value ?? 0);
  13. // 如果在线支付方式出现变动,改变 在线支付 设置状态
  14. if (Arr::exists(['is_AliPay', 'is_QQPay', 'is_WeChatPay', 'is_otherPay'], $config->name) && Cache::tags('sysConfig')->has('is_onlinePay')) {
  15. Helpers::cacheSysConfig('is_onlinePay');
  16. }
  17. }
  18. }