Config.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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', 36);
  22. $pc28_switch = intval($pc28_switch);
  23. $val = static::where('field', 'pc28_switch')->first()->val;
  24. $val = intval($val);
  25. $m = new Message();
  26. $m->json = json_encode([
  27. 'pc28_switch' => $pc28_switch,
  28. 'val' => $val
  29. ]);
  30. $m->save();
  31. if (!in_array($pc28_switch,[0,1])) $pc28_switch = $val;
  32. if ($pc28_switch !== $val) {
  33. static::where('field', 'pc28_switch')->update(['val' => $pc28_switch]);
  34. $lang = App::getLocale();
  35. $group_language = static::where('field', 'group_language')->first()->val;
  36. App::setLocale($group_language);
  37. $groupText = "------" . lang("已切换为极速PC28") . "------";
  38. if ($pc28_switch == 0) $groupText = "-----" . lang("已切换为加拿大PC28") . "------";
  39. App::setLocale($lang);
  40. ConfigService::asyncBettingGroupNotice($groupText, isTop: true); // 异步群通知
  41. }
  42. }
  43. }