File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -532,7 +532,7 @@ public function resolveIndexRelationships($request)
532532 return $ this ->resolveRelationships ($ request );
533533 }
534534
535- public function index (RestifyRequest $ request )
535+ public function index (RestifyRequest $ request, bool $ toArray = false )
536536 {
537537 // Check if the user has the policy allowRestify
538538
@@ -558,7 +558,7 @@ public function index(RestifyRequest $request)
558558
559559 $ data = $ items ->map (fn (self $ repository ) => $ repository ->serializeForIndex ($ request ));
560560
561- return response ()-> json ( $ this ->filter ([
561+ $ result = $ this ->filter ([
562562 'meta ' => $ this ->when (
563563 $ meta = $ this ->resolveIndexMainMeta (
564564 $ request ,
@@ -586,7 +586,13 @@ public function index(RestifyRequest $request)
586586 $ links
587587 ),
588588 'data ' => $ data ,
589- ]));
589+ ]);
590+
591+ if ($ toArray ) {
592+ return $ result ;
593+ }
594+
595+ return response ()->json ($ result );
590596 }
591597
592598 public function indexCollection (RestifyRequest $ request , Collection $ items ): Collection
You can’t perform that action at this time.
0 commit comments