connection = DB::connection((string) config('upstream_mirrors.connection', 'business_mirror')); } public function available(): bool { return Schema::connection($this->connection->getName())->hasTable(self::TABLE); } /** @return list> 启用中的规则,按 sort、id 升序 */ public function activeRules(): array { if (! $this->available()) { return []; } return $this->connection->table(self::TABLE) ->where('enabled', true) ->orderBy('sort') ->orderBy('id') ->get() ->map(static fn (object $row): array => (array) $row) ->all(); } /** @return list> 全部规则(后台维护用),按 sort、id 升序 */ public function all(): array { if (! $this->available()) { return []; } return $this->connection->table(self::TABLE) ->orderBy('sort') ->orderBy('id') ->get() ->map(static fn (object $row): array => (array) $row) ->all(); } }