Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Repositories/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ public function resolveIndexRelationships($request)
return $this->resolveRelationships($request);
}

public function index(RestifyRequest $request)
public function index(RestifyRequest $request, bool $toArray = false)
{
// Check if the user has the policy allowRestify

Expand All @@ -558,7 +558,7 @@ public function index(RestifyRequest $request)

$data = $items->map(fn (self $repository) => $repository->serializeForIndex($request));

return response()->json($this->filter([
$result = $this->filter([
'meta' => $this->when(
$meta = $this->resolveIndexMainMeta(
$request,
Expand Down Expand Up @@ -586,7 +586,13 @@ public function index(RestifyRequest $request)
$links
),
'data' => $data,
]));
]);

if ($toArray) {
return $result;
}

return response()->json($result);
}

public function indexCollection(RestifyRequest $request, Collection $items): Collection
Expand Down
Loading