Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/Http/Controllers/RepositoryFilterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public function __invoke(RepositoryFiltersRequest $request)

return $this->response()->data(
$repository->availableFilters($request)
->when(Str::contains($request->input('include'), 'matches'), function (Collection $collection) use ($repository) {
->when(Str::contains($request->input('include'), 'matches'), function (Collection $collection) use ($repository) {
return $collection->merge(
MatchFilter::makeForRepository($repository)
);
})
->when(Str::contains($request->input('include'), 'sortable'), function (Collection $collection) use ($repository) {
->when(Str::contains($request->input('include'), 'sortable'), function (Collection $collection) use ($repository) {
return $collection->merge(
SortableFilter::makeForRepository($repository)
);
Expand Down
1 change: 1 addition & 0 deletions src/Repositories/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ public function resolveRelationships($request): array
->each(function ($relation) use ($request, $withs) {
if (Str::contains($relation, '.')) {
$this->resource->loadMissing($relation);

return $withs->put($key = Str::before($relation, '.'), Arr::get($this->resource->relationsToArray(), $key));
}

Expand Down
7 changes: 3 additions & 4 deletions tests/Controllers/RepositoryFilterControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public function test_available_filters_contains_matches()
// 1 sort
->assertJsonCount(6, 'data');


$this->assertSame(
$response->json('data.4.key'), 'matches'
);
Expand Down Expand Up @@ -62,7 +61,7 @@ public function test_value_filter_doesnt_require_value()

$response = $this
->withoutExceptionHandling()
->getJson('posts?filters=' . $filters)
->getJson('posts?filters='.$filters)
->assertStatus(200);

$this->assertCount(1, $response->json('data'));
Expand All @@ -84,7 +83,7 @@ public function test_the_boolean_filter_is_applied()

$response = $this
->withoutExceptionHandling()
->getJson('posts?filters=' . $filters)
->getJson('posts?filters='.$filters)
->assertStatus(200);

$this->assertCount(1, $response->json('data'));
Expand All @@ -104,7 +103,7 @@ public function test_the_select_filter_is_applied()

$response = $this
->withExceptionHandling()
->getJson('posts?filters=' . $filters)
->getJson('posts?filters='.$filters)
->assertStatus(200);

$this->assertCount(1, $response->json('data'));
Expand Down
2 changes: 1 addition & 1 deletion tests/Controllers/RepositoryIndexControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function test_repository_with_deep_relations()
});
});

$response = $this->getJson(CompanyRepository::uriKey() . '?related=users.posts')
$response = $this->getJson(CompanyRepository::uriKey().'?related=users.posts')
->assertOk();

$this->assertCount(1, $response->json('data.0.relationships.users'));
Expand Down