$settings->effectiveForForm(), ]); } public function update(Request $request, SettingsService $settings) { $data = $request->validate([ 'telegram_bot_token' => ['nullable', 'string', 'max:255'], 'telegram_owner_chat_id' => ['nullable', 'string', 'max:64'], 'channels_max_per_agent' => ['nullable', 'integer', 'min:1', 'max:100'], 'channels_domains' => ['nullable', 'string', 'max:4000'], 'panel_admin_hosts' => ['nullable', 'string', 'max:4000'], 'panel_agent_hosts' => ['nullable', 'string', 'max:4000'], ]); $domains = SettingsService::parseDomains($data['channels_domains'] ?? null); $adminHosts = SettingsService::parseDomains($data['panel_admin_hosts'] ?? null); $agentHosts = SettingsService::parseDomains($data['panel_agent_hosts'] ?? null); $settings->putMany([ 'telegram.bot_token' => $data['telegram_bot_token'] ?? null, 'telegram.owner_chat_id' => $data['telegram_owner_chat_id'] ?? null, 'channels.max_per_agent' => isset($data['channels_max_per_agent']) ? (string) $data['channels_max_per_agent'] : null, // Persist normalized comma-separated list (empty clears override to []). 'channels.domains' => $domains === [] ? '' : implode(',', $domains), // Empty = no Host restriction for that panel. 'panel.admin_hosts' => $adminHosts === [] ? '' : implode(',', $adminHosts), 'panel.agent_hosts' => $agentHosts === [] ? '' : implode(',', $agentHosts), ]); return response()->json(['code' => 0, 'msg' => '已保存']); } }