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 diff --git a/src/Controllers/RestResponse.php b/src/Controllers/RestResponse.php index 15b8a3344..e5020a3dc 100644 --- a/src/Controllers/RestResponse.php +++ b/src/Controllers/RestResponse.php @@ -276,14 +276,6 @@ public function respond($response = null) foreach ($this->attributes as $attribute => $value) { $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: diff --git a/src/Services/Search/SearchService.php b/src/Services/Search/SearchService.php index 4bb048518..83d8a38a5 100644 --- a/src/Services/Search/SearchService.php +++ b/src/Services/Search/SearchService.php @@ -8,6 +8,11 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; +/** + * Class SearchService. + * + * Props to @Koenster for contribution + */ class SearchService extends Searchable { /** 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(); }