From a956ebe397b8629be31d74b5050c5f61158c544d Mon Sep 17 00:00:00 2001 From: Lupacescu Eduard Date: Tue, 8 Dec 2020 10:27:08 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/Http/Controllers/RepositoryFilterController.php | 4 ++-- src/Repositories/Repository.php | 1 + tests/Controllers/RepositoryFilterControllerTest.php | 7 +++---- tests/Controllers/RepositoryIndexControllerTest.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Http/Controllers/RepositoryFilterController.php b/src/Http/Controllers/RepositoryFilterController.php index 72ac43932..08b8eac18 100644 --- a/src/Http/Controllers/RepositoryFilterController.php +++ b/src/Http/Controllers/RepositoryFilterController.php @@ -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) ); diff --git a/src/Repositories/Repository.php b/src/Repositories/Repository.php index 2459f095b..d1114971a 100644 --- a/src/Repositories/Repository.php +++ b/src/Repositories/Repository.php @@ -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)); } diff --git a/tests/Controllers/RepositoryFilterControllerTest.php b/tests/Controllers/RepositoryFilterControllerTest.php index ec082bd19..a866c3715 100644 --- a/tests/Controllers/RepositoryFilterControllerTest.php +++ b/tests/Controllers/RepositoryFilterControllerTest.php @@ -34,7 +34,6 @@ public function test_available_filters_contains_matches() // 1 sort ->assertJsonCount(6, 'data'); - $this->assertSame( $response->json('data.4.key'), 'matches' ); @@ -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')); @@ -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')); @@ -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')); diff --git a/tests/Controllers/RepositoryIndexControllerTest.php b/tests/Controllers/RepositoryIndexControllerTest.php index ccc1144d7..6389d757f 100644 --- a/tests/Controllers/RepositoryIndexControllerTest.php +++ b/tests/Controllers/RepositoryIndexControllerTest.php @@ -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'));