File tree Expand file tree Collapse file tree 1 file changed +24
-4
lines changed
app/Filament/Pages/Settings Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -81,11 +81,31 @@ public function form(Form $form): Form
8181 Forms \Components \Select::make ('speedtest_server ' )
8282 ->label ('Speedtest servers ' )
8383 ->helperText ('Leave empty to let the system pick the best server. ' )
84- ->nullable ()
85- ->multiple ()
8684 ->maxItems (10 )
87- ->preload ()
85+ ->multiple ()
86+ ->nullable ()
87+ ->preload (false )
8888 ->searchable ()
89+ ->options (function (): array {
90+ $ response = Http::get (
91+ url: 'https://www.speedtest.net/api/js/servers ' ,
92+ query: [
93+ 'engine ' => 'js ' ,
94+ 'https_functional ' => true ,
95+ 'limit ' => 20 ,
96+ ]
97+ );
98+
99+ if ($ response ->failed ()) {
100+ return [
101+ '' => 'There was an error retrieving Speedtest servers ' ,
102+ ];
103+ }
104+
105+ return $ response ->collect ()->mapWithKeys (function (array $ item , int $ key ) {
106+ return [$ item ['id ' ] => $ item ['id ' ].': ' .$ item ['name ' ].' ( ' .$ item ['sponsor ' ].') ' ];
107+ })->toArray ();
108+ })
89109 ->getSearchResultsUsing (fn (string $ search ): array => $ this ->getServerSearchOptions ($ search ))
90110 ->getOptionLabelsUsing (fn (array $ values ): array => $ this ->getServerLabels ($ values ))
91111 ->columnSpan ('full ' ),
@@ -119,7 +139,7 @@ protected function getServerSearchOptions(string $search): array
119139 'engine ' => 'js ' ,
120140 'search ' => $ search ,
121141 'https_functional ' => true ,
122- 'limit ' => 10 ,
142+ 'limit ' => 20 ,
123143 ]
124144 );
125145
You can’t perform that action at this time.
0 commit comments