@@ -288,7 +288,22 @@ protected function selectableValuesFormFields(string $type, string $label, strin
288288 Select::make ('relationKey ' )
289289 ->label (__ ('Key Column ' ))
290290 ->helperText (__ ('The column to use as the unique identifier/value for each option ' ))
291- ->options (fn (Get $ get ) => $ get ('relationKey_options ' ) ?? [])
291+ ->options (function (Get $ get ) {
292+ $ resource = $ get ('resource ' );
293+ if (!$ resource ) {
294+ return [];
295+ }
296+
297+ $ model = static ::resolveResourceModel ($ resource );
298+ if (!$ model ) {
299+ return [];
300+ }
301+
302+ $ columns = Schema::getColumnListing ($ model ->getTable ());
303+ return collect ($ columns )->mapWithKeys (function ($ column ) {
304+ return [$ column => Str::title ($ column )];
305+ })->toArray ();
306+ })
292307 ->searchable ()
293308 ->visible (fn (Get $ get ): bool => ! empty ($ get ('resource ' )))
294309 ->required (
@@ -298,7 +313,22 @@ protected function selectableValuesFormFields(string $type, string $label, strin
298313 Select::make ('relationValue ' )
299314 ->label (__ ('Display Column ' ))
300315 ->helperText (__ ('The column to use as the display text/label for each option ' ))
301- ->options (fn (Get $ get ) => $ get ('relationValue_options ' ) ?? [])
316+ ->options (function (Get $ get ) {
317+ $ resource = $ get ('resource ' );
318+ if (!$ resource ) {
319+ return [];
320+ }
321+
322+ $ model = static ::resolveResourceModel ($ resource );
323+ if (!$ model ) {
324+ return [];
325+ }
326+
327+ $ columns = Schema::getColumnListing ($ model ->getTable ());
328+ return collect ($ columns )->mapWithKeys (function ($ column ) {
329+ return [$ column => Str::title ($ column )];
330+ })->toArray ();
331+ })
302332 ->searchable ()
303333 ->visible (fn (Get $ get ): bool => ! empty ($ get ('resource ' )))
304334 ->required (fn (Get $ get ): bool => ! empty ($ get ('resource ' ))),
@@ -318,7 +348,7 @@ protected function selectableValuesFormFields(string $type, string $label, strin
318348 Select::make ('operator ' )
319349 ->options ([
320350 '= ' => __ ('Equal ' ),
321- '!= ' => __ ('Not equal ' ),
351+ '!= ' => __ ('Not equal ' ),
322352 '> ' => __ ('Greater than ' ),
323353 '< ' => __ ('Less than ' ),
324354 '>= ' => __ ('Greater than or equal to ' ),
0 commit comments