Config.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Models;
  3. use App\Services\ConfigService;
  4. use Illuminate\Support\Facades\App;
  5. use Illuminate\Support\Facades\Cache;
  6. class Config extends BaseModel
  7. {
  8. protected $table = 'config';
  9. protected $fillable = ['field', 'val', 'remark', 'group_id'];
  10. /*
  11. * group_id
  12. * 1 系统基础配置
  13. * 2 频道消息配置
  14. * 3 用户自定义配置
  15. * 4 极速PC28相关配置
  16. *
  17. *
  18. */
  19. public static function setPc28Switch()
  20. {
  21. $pc28_switch = Cache::get('pc28_switch');
  22. $val = static::where('field', 'pc28_switch')->first()->val;
  23. if ($pc28_switch == null) $pc28_switch = $val;
  24. if ($pc28_switch != $val) {
  25. static::where('field', 'pc28_switch')->update(['val' => $pc28_switch]);
  26. $lang = App::getLocale();
  27. $group_language = static::where('field', 'group_language')->first()->val;
  28. App::setLocale($group_language);
  29. $groupText = "------" . lang("已切换为极速PC28") . "------";
  30. if ($pc28_switch == 0) $groupText = "-----" . lang("已切换为加拿大PC28") . "------";
  31. App::setLocale($lang);
  32. ConfigService::asyncBettingGroupNotice($groupText, isTop: true); // 异步群通知
  33. }
  34. }
  35. }