add crud api global setting and make global api response and handle response web and api on bootstrap app
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
@@ -15,8 +16,13 @@ return Application::configure(basePath: dirname(__DIR__))
|
||||
->withMiddleware(function (Middleware $middleware) {
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions) {
|
||||
$exceptions->render(function (HttpException $exception){
|
||||
if($exception->getStatusCode() == 404) {
|
||||
$exceptions->shouldRenderJsonWhen(function (Request $request, Throwable $th){
|
||||
if($request->is('api/*')){
|
||||
return true;
|
||||
}
|
||||
});
|
||||
$exceptions->render(function (HttpException $exception, Request $request){
|
||||
if($exception->getStatusCode() == 404 && $request->isNot('api/*')) {
|
||||
return response()->view('pages.404',[],404);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user