label(__('Update GeoIP Database')) ->icon('heroicon-o-arrow-down-tray') ->form([ TextInput::make('account_id') ->label(__('MaxMind Account ID')) ->required() ->default(fn (): string => (string) (DnsSetting::get('geoip_account_id') ?? '')), TextInput::make('license_key') ->label(__('MaxMind License Key')) ->password() ->revealable() ->required() ->default(fn (): string => (string) (DnsSetting::get('geoip_license_key') ?? '')), TextInput::make('edition_ids') ->label(__('Edition IDs')) ->helperText(__('Comma-separated (default: GeoLite2-Country)')) ->default(fn (): string => (string) (DnsSetting::get('geoip_edition_ids') ?? 'GeoLite2-Country')), ]) ->action(function (array $data): void { $accountId = trim((string) ($data['account_id'] ?? '')); $licenseKey = trim((string) ($data['license_key'] ?? '')); $editionIds = trim((string) ($data['edition_ids'] ?? 'GeoLite2-Country')); if ($accountId === '' || $licenseKey === '') { Notification::make() ->title(__('MaxMind credentials are required')) ->danger() ->send(); return; } DnsSetting::set('geoip_account_id', $accountId); DnsSetting::set('geoip_license_key', $licenseKey); DnsSetting::set('geoip_edition_ids', $editionIds); try { $agent = new AgentClient; $result = $agent->geoUpdateDatabase($accountId, $licenseKey, $editionIds); Notification::make() ->title(__('GeoIP database updated')) ->body($result['path'] ?? null) ->success() ->send(); } catch (Exception $e) { Notification::make() ->title(__('GeoIP update failed')) ->body($e->getMessage()) ->danger() ->send(); } }), CreateAction::make(), ]; } }