File tree 3 files changed +951
-1051
lines changed
3 files changed +951
-1051
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ use Illuminate \Database \Eloquent \ModelNotFoundException ;
3
4
use Illuminate \Foundation \Application ;
4
5
use Illuminate \Foundation \Configuration \Exceptions ;
5
6
use Illuminate \Foundation \Configuration \Middleware ;
6
7
use Illuminate \Routing \Middleware \SubstituteBindings ;
7
8
use Illuminate \Support \Facades \Route ;
9
+ use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
8
10
9
11
return Application::configure (basePath: dirname (__DIR__ ))
10
12
->withRouting (
22
24
//
23
25
})
24
26
->withExceptions (function (Exceptions $ exceptions ) {
25
- //
27
+ $ exceptions ->render (function (NotFoundHttpException $ e , \Illuminate \Http \Request $ request ) {
28
+ if ($ request ->wantsJson () && $ e ->getPrevious () instanceof ModelNotFoundException) {
29
+ return response ()->json ([
30
+ 'message ' =>
31
+ sprintf ('Requested %s couldn \'t be found. ' , class_basename ($ e ->getPrevious ()->getModel ())),
32
+ ], 404 );
33
+ }
34
+ });
26
35
})->create ();
You can’t perform that action at this time.
0 commit comments