Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

return response not found laravel api response

// In Laravel 9
// Update register() in App/Exceptions/Handler.php
use SymfonyComponentHttpKernelExceptionNotFoundHttpException;

public function register()
{
    $this->renderable(function (NotFoundHttpException $e, $request) {
        if ($request->is('api/*')) {
            return response()->json([
                'message' => 'Not found.'
            ], 404);
        }
    });
}
 
PREVIOUS NEXT
Tagged: #return #response #laravel #api #response
ADD COMMENT
Topic
Name
9+1 =