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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## V2.1.0

+ Update outdated json error response

## V2.0.0

+ Upgrade to Laravel 9 and update related dependencies
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"illuminate/support": "^9.0",
"illuminate/session": "^9.0",
"illuminate/pagination": "^9.0",
"mblsolutions/inspireddeck-php": "^1.5|^2.0"
"mblsolutions/inspireddeck-php": "^2.0"
},
"require-dev": {
"orchestra/testbench": "^7.0",
"phpunit/phpunit": "^9.0"
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 4 additions & 4 deletions src/InspiredDeckServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace MBLSolutions\InspiredDeckLaravel;

use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\ServiceProvider;
use MBLSolutions\InspiredDeck\Exceptions\NotFoundException;
Expand All @@ -12,6 +11,7 @@
use MBLSolutions\InspiredDeck\InspiredDeck;
use MBLSolutions\InspiredDeckLaravel\Middleware\LoadInspiredDeckConfig;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Support\Facades\Response;

class InspiredDeckServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -64,13 +64,13 @@ public function registerMiddleware($middleware)
* @param $request
* @param $exception
* @param callable|null $function
* @return JsonResponse|RedirectResponse
* @return \Illuminate\Http\JsonResponse|RedirectResponse
*/
public static function exceptionHandling($request, $exception, callable $function = null)
{
if (route_contains('async') || route_contains('api')) {
if ($exception instanceof ValidationException) {
return JsonResponse::create([
return Response::json([
'message' => $exception->getMessage(),
'errors' => $exception->getValidationErrors()
], $exception->getCode());
Expand Down Expand Up @@ -98,4 +98,4 @@ public static function exceptionHandling($request, $exception, callable $functio
return $function();
}

}
}