Skip to content

Commit

Permalink
fix: don't check related if no query (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryk authored Jul 13, 2022
1 parent 6e0e244 commit 5a9b405
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Filters/RelatedDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ public function getColumnsFor(string $relation): array|string
? $columns
: '*';
}

public function hasRelated(): bool
{
return ! empty($this->related);
}
}
4 changes: 4 additions & 0 deletions src/Repositories/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ public function resolveIndexPivots(RestifyRequest $request): array
*/
public function resolveRelationships($request): array
{
if (! $request->related()->hasRelated()) {
return [];
}

return static::collectRelated()
->authorized($request)
->inRequest($request)
Expand Down

0 comments on commit 5a9b405

Please sign in to comment.