Skip to content

Commit dbf68b7

Browse files
rsloan-mlbsolutionsRachel Sloan
andauthored
Bug/fix error response (#6)
* Add changelog * Update dependency versions * Fix json response method to work with Laravel 9 Co-authored-by: Rachel Sloan <rachel.sloan@mlbsolutions.co.uk>
1 parent 5e18e96 commit dbf68b7

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## V2.1.0
2+
3+
+ Update outdated json error response
4+
5+
## V2.0.0
6+
7+
+ Upgrade to Laravel 9 and update related dependencies

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
"illuminate/support": "^9.0",
1818
"illuminate/session": "^9.0",
1919
"illuminate/pagination": "^9.0",
20-
"mblsolutions/inspireddeck-php": "^1.5|^2.0"
20+
"mblsolutions/inspireddeck-php": "^2.0"
2121
},
2222
"require-dev": {
2323
"orchestra/testbench": "^7.0",
24-
"phpunit/phpunit": "^9.0"
24+
"phpunit/phpunit": "^9.5"
2525
},
2626
"autoload": {
2727
"psr-4": {

src/InspiredDeckServiceProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace MBLSolutions\InspiredDeckLaravel;
44

55
use Illuminate\Contracts\Http\Kernel;
6-
use Illuminate\Http\JsonResponse;
76
use Illuminate\Http\RedirectResponse;
87
use Illuminate\Support\ServiceProvider;
98
use MBLSolutions\InspiredDeck\Exceptions\NotFoundException;
@@ -12,6 +11,7 @@
1211
use MBLSolutions\InspiredDeck\InspiredDeck;
1312
use MBLSolutions\InspiredDeckLaravel\Middleware\LoadInspiredDeckConfig;
1413
use Symfony\Component\HttpKernel\Exception\HttpException;
14+
use Illuminate\Support\Facades\Response;
1515

1616
class InspiredDeckServiceProvider extends ServiceProvider
1717
{
@@ -64,13 +64,13 @@ public function registerMiddleware($middleware)
6464
* @param $request
6565
* @param $exception
6666
* @param callable|null $function
67-
* @return JsonResponse|RedirectResponse
67+
* @return \Illuminate\Http\JsonResponse|RedirectResponse
6868
*/
6969
public static function exceptionHandling($request, $exception, callable $function = null)
7070
{
7171
if (route_contains('async') || route_contains('api')) {
7272
if ($exception instanceof ValidationException) {
73-
return JsonResponse::create([
73+
return Response::json([
7474
'message' => $exception->getMessage(),
7575
'errors' => $exception->getValidationErrors()
7676
], $exception->getCode());
@@ -98,4 +98,4 @@ public static function exceptionHandling($request, $exception, callable $functio
9898
return $function();
9999
}
100100

101-
}
101+
}

0 commit comments

Comments
 (0)