From b0f83ae616729f1ac8c217c2f33ee59936199c99 Mon Sep 17 00:00:00 2001 From: Lupacescu Eduard Date: Mon, 23 Dec 2019 17:23:08 +0200 Subject: [PATCH 1/6] Clean up --- src/Controllers/RestResponse.php | 8 +------- src/Exceptions/RestifyHandler.php | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Controllers/RestResponse.php b/src/Controllers/RestResponse.php index 15b8a3344..b7392b120 100644 --- a/src/Controllers/RestResponse.php +++ b/src/Controllers/RestResponse.php @@ -4,6 +4,7 @@ use Illuminate\Contracts\Routing\ResponseFactory; use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Database\Eloquent\Model; use Illuminate\Http\JsonResponse; /** @@ -277,13 +278,6 @@ public function respond($response = null) $response->{$attribute} = $value; } - if (is_iterable($response)) { - foreach ($response as $property => $value) { - if ($value instanceof Arrayable) { - $response->{$property} = $value->toArray(); - } - } - } } return $this->response()->json($response, is_int($this->code()) ? $this->code() : self::REST_RESPONSE_SUCCESS_CODE, $this->headers); diff --git a/src/Exceptions/RestifyHandler.php b/src/Exceptions/RestifyHandler.php index 2e3d1e822..3832b2b06 100644 --- a/src/Exceptions/RestifyHandler.php +++ b/src/Exceptions/RestifyHandler.php @@ -18,7 +18,7 @@ use Illuminate\Http\Response; use Illuminate\Routing\Exceptions\InvalidSignatureException; use Illuminate\Support\Facades\App; -use Illuminate\Validation\UnauthorizedException; +use Illuminate\Validation\UnauthorizedException as ValidationUnauthorized; use Illuminate\Validation\ValidationException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; @@ -90,7 +90,7 @@ public function render($request, Exception $exception) case $exception instanceof BadRequestHttpException: case $exception instanceof MethodNotAllowedException: - case $exception instanceof UnauthorizedException: + case $exception instanceof ValidationUnauthorized: case $exception instanceof UnauthorizedHttpException: case $exception instanceof UnauthenticateException: case $exception instanceof ActionUnauthorizedException: From 424c0181ced25cdc194ee8ec67772198ab99c00e Mon Sep 17 00:00:00 2001 From: Lupacescu Eduard Date: Mon, 23 Dec 2019 17:23:26 +0200 Subject: [PATCH 2/6] Apply fixes from StyleCI (#60) --- src/Controllers/RestResponse.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Controllers/RestResponse.php b/src/Controllers/RestResponse.php index b7392b120..e5020a3dc 100644 --- a/src/Controllers/RestResponse.php +++ b/src/Controllers/RestResponse.php @@ -4,7 +4,6 @@ use Illuminate\Contracts\Routing\ResponseFactory; use Illuminate\Contracts\Support\Arrayable; -use Illuminate\Database\Eloquent\Model; use Illuminate\Http\JsonResponse; /** @@ -277,7 +276,6 @@ public function respond($response = null) foreach ($this->attributes as $attribute => $value) { $response->{$attribute} = $value; } - } return $this->response()->json($response, is_int($this->code()) ? $this->code() : self::REST_RESPONSE_SUCCESS_CODE, $this->headers); From 70d2bb8cd33b7d59d1d3cf98373ea5a3160615a4 Mon Sep 17 00:00:00 2001 From: Lupacescu Eduard Date: Mon, 23 Dec 2019 17:28:31 +0200 Subject: [PATCH 3/6] Clean up --- src/Traits/InteractWithSearch.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Traits/InteractWithSearch.php b/src/Traits/InteractWithSearch.php index e6d04333a..54da86a4d 100644 --- a/src/Traits/InteractWithSearch.php +++ b/src/Traits/InteractWithSearch.php @@ -69,4 +69,9 @@ public function serializeForIndex(RestifyRequest $request, array $fields = null) 'authorizedToDelete' => $this->authorizedToDelete($request), ]); } + + /** + * @return array + */ + abstract public function toArray(); } From 9e86db8e0b49928634c1abe4c43608911519e440 Mon Sep 17 00:00:00 2001 From: Lupacescu Eduard Date: Mon, 23 Dec 2019 17:36:50 +0200 Subject: [PATCH 4/6] Props --- src/Services/Search/SearchService.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Services/Search/SearchService.php b/src/Services/Search/SearchService.php index 4bb048518..88097fa44 100644 --- a/src/Services/Search/SearchService.php +++ b/src/Services/Search/SearchService.php @@ -8,6 +8,13 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; +/** + * Class SearchService + * + * Props to @Koenster for contribution + * + * @package Binaryk\LaravelRestify\Services\Search + */ class SearchService extends Searchable { /** From edf196ddb2da9f1314e8c88cb48881b49bdc4191 Mon Sep 17 00:00:00 2001 From: Lupacescu Eduard Date: Mon, 23 Dec 2019 17:37:07 +0200 Subject: [PATCH 5/6] Apply fixes from StyleCI (#61) --- src/Services/Search/SearchService.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Services/Search/SearchService.php b/src/Services/Search/SearchService.php index 88097fa44..83d8a38a5 100644 --- a/src/Services/Search/SearchService.php +++ b/src/Services/Search/SearchService.php @@ -9,11 +9,9 @@ use Illuminate\Database\Eloquent\Model; /** - * Class SearchService + * Class SearchService. * * Props to @Koenster for contribution - * - * @package Binaryk\LaravelRestify\Services\Search */ class SearchService extends Searchable { From f07677b370287ccee98d6ff724207402e1306943 Mon Sep 17 00:00:00 2001 From: Lupacescu Eduard Date: Mon, 23 Dec 2019 17:38:12 +0200 Subject: [PATCH 6/6] Props --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e556cae61..1bcf0b82c 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ If you discover any security related issues, please email eduard.lupacescu@binar ## Credits - [Eduard Lupacescu](https://github.com/binaryk) +- [Koen Koenster](https://github.com/Koenster) - [All Contributors](../../contributors) ## License