@@ -436,28 +436,11 @@ public function resolveShowAttributes(RestifyRequest $request)
436436 */
437437 public function resolveIndexAttributes ($ request )
438438 {
439- // Resolve the show method, and attach the value to the array
440- $ fields = $ this
441- ->collectFields ($ request )
442- ->when ($ this ->hasCustomColumns (), fn (FieldCollection $ fields ) => $ fields ->inList ($ this ->getColumns ()))
443- ->forIndex ($ request , $ this )
444- ->filter (fn (Field $ field ) => $ field ->authorize ($ request ))
445- ->when (
446- $ this ->eagerState ,
447- function ($ items ) {
448- return $ items ->filter (fn (Field $ field ) => ! $ field instanceof EagerField);
449- }
450- )
451- ->each (fn (Field $ field ) => $ field ->resolveForIndex ($ this ))
452- ->map (fn (Field $ field ) => $ field ->serializeToValue ($ request ))
453- ->mapWithKeys (fn ($ value ) => $ value )
454- ->all ();
455-
456439 if ($ this instanceof Mergeable) {
457440 // Hidden and authorized index fields
458- $ fields = $ this ->modelAttributes ($ request )
441+ return $ this ->modelAttributes ($ request )
459442 ->filter (function ($ value , $ attribute ) use ($ request ) {
460- /** * @var Field $field */
443+ /** @var Field $field */
461444 $ field = $ this ->collectFields ($ request )->firstWhere ('attribute ' , $ attribute );
462445
463446 if (is_null ($ field )) {
@@ -476,7 +459,23 @@ function ($items) {
476459 })->all ();
477460 }
478461
479- return $ fields ;
462+ // Resolve the show method, and attach the value to the array
463+ return $ this
464+ ->collectFields ($ request )
465+ ->when (
466+ $ this ->hasCustomColumns (),
467+ fn (FieldCollection $ fields ) => $ fields ->inList ($ this ->getColumns ())
468+ )
469+ ->forIndex ($ request , $ this )
470+ ->filter (fn (Field $ field ) => $ field ->authorize ($ request ))
471+ ->when (
472+ $ this ->eagerState ,
473+ fn ($ items ) => $ items ->filter (fn (Field $ field ) => ! $ field instanceof EagerField)
474+ )
475+ ->each (fn (Field $ field ) => $ field ->resolveForIndex ($ this ))
476+ ->map (fn (Field $ field ) => $ field ->serializeToValue ($ request ))
477+ ->mapWithKeys (fn ($ value ) => $ value )
478+ ->all ();
480479 }
481480
482481 public function resolveShowMeta ($ request )
0 commit comments