3
3
namespace MBLSolutions \InspiredDeckLaravel ;
4
4
5
5
use Illuminate \Contracts \Http \Kernel ;
6
- use Illuminate \Http \JsonResponse ;
7
6
use Illuminate \Http \RedirectResponse ;
8
7
use Illuminate \Support \ServiceProvider ;
9
8
use MBLSolutions \InspiredDeck \Exceptions \NotFoundException ;
12
11
use MBLSolutions \InspiredDeck \InspiredDeck ;
13
12
use MBLSolutions \InspiredDeckLaravel \Middleware \LoadInspiredDeckConfig ;
14
13
use Symfony \Component \HttpKernel \Exception \HttpException ;
14
+ use Illuminate \Support \Facades \Response ;
15
15
16
16
class InspiredDeckServiceProvider extends ServiceProvider
17
17
{
@@ -64,13 +64,13 @@ public function registerMiddleware($middleware)
64
64
* @param $request
65
65
* @param $exception
66
66
* @param callable|null $function
67
- * @return JsonResponse|RedirectResponse
67
+ * @return \Illuminate\Http\ JsonResponse|RedirectResponse
68
68
*/
69
69
public static function exceptionHandling ($ request , $ exception , callable $ function = null )
70
70
{
71
71
if (route_contains ('async ' ) || route_contains ('api ' )) {
72
72
if ($ exception instanceof ValidationException) {
73
- return JsonResponse:: create ([
73
+ return Response:: json ([
74
74
'message ' => $ exception ->getMessage (),
75
75
'errors ' => $ exception ->getValidationErrors ()
76
76
], $ exception ->getCode ());
@@ -98,4 +98,4 @@ public static function exceptionHandling($request, $exception, callable $functio
98
98
return $ function ();
99
99
}
100
100
101
- }
101
+ }
0 commit comments