File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 1515use Binaryk \LaravelRestify \Traits \InteractWithSearch ;
1616use Binaryk \LaravelRestify \Traits \PerformsQueries ;
1717use Illuminate \Contracts \Pagination \LengthAwarePaginator ;
18+ use Illuminate \Database \Eloquent \Builder ;
1819use Illuminate \Database \Eloquent \Model ;
20+ use Illuminate \Database \Eloquent \Relations \Relation ;
1921use Illuminate \Http \Request ;
2022use Illuminate \Http \Resources \ConditionallyLoadsAttributes ;
2123use Illuminate \Http \Resources \DelegatesToResource ;
@@ -520,15 +522,22 @@ public function resolveRelationships($request): array
520522 $ paginator = $ this ->resource ->{$ relation }();
521523
522524 if ($ paginator instanceof Model) {
525+ $ withs [$ relation ] = $ paginator ;
523526 continue ;
524527 }
525528
526529 if ($ paginator instanceof Collection) {
530+ $ withs [$ relation ] = $ paginator ;
527531 continue ;
528532 }
529533
530- /** * @var AbstractPaginator $paginator */
531- $ paginator = $ paginator ->take ($ request ->input ('relatablePerPage ' ) ?? (static ::$ defaultRelatablePerPage ?? RestifySearchable::DEFAULT_RELATABLE_PER_PAGE ))->get ();
534+ if (
535+ $ paginator instanceof Relation ||
536+ $ paginator instanceof Builder
537+ ) {
538+ /** * @var AbstractPaginator $paginator */
539+ $ paginator = $ paginator ->take ($ request ->input ('relatablePerPage ' ) ?? (static ::$ defaultRelatablePerPage ?? RestifySearchable::DEFAULT_RELATABLE_PER_PAGE ))->get ();
540+ }
532541 }
533542
534543 $ withs [$ relation ] = $ paginator instanceof Collection
You can’t perform that action at this time.
0 commit comments