ProxyConfig.php 735 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace App\Helpers;
  3. use App\Models\SsConfig;
  4. trait ProxyConfig
  5. {
  6. private function proxyConfigOptions(): array
  7. {
  8. // 一次性获取所有配置数据
  9. $configs = SsConfig::get(['name', 'type'])->groupBy('type')->map(fn ($items) => $items->pluck('name', 'name'));
  10. // 获取默认配置项
  11. $defaults = SsConfig::where('is_default', 1)->pluck('name', 'type');
  12. return [
  13. 'methods' => $configs->get(1, []),
  14. 'protocols' => $configs->get(2, []),
  15. 'obfs' => $configs->get(3, []),
  16. 'methodDefault' => $defaults->get(1),
  17. 'protocolDefault' => $defaults->get(2),
  18. 'obfsDefault' => $defaults->get(3),
  19. ];
  20. }
  21. }