app/Exceptions/Handler.php
/**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Throwable  $exception
     * @return \Symfony\Component\HttpFoundation\Response
     *
     * @throws \Throwable
     */
Render an exception into an HTTP response.

@throws \Throwable
Render an exception into an HTTP response . @throws \ Throwable
public function render($request, Throwable $exception)
    {
        if ($exception instanceof ModelNotFoundException) {
            $model = explode('\\', $exception->getModel());
            $modelPhrase = ucwords(implode(' ',preg_split('/(?=[A-Z])/', end($model))));
            return response()->json([
                'error' => \App::make($exception->getModel())->modelNotFoundMessage ?? $modelPhrase . ' not found'
            ], 404);
        }
        return parent::render($request, $exception);
    }
public function render ( $ request , Throwable $ exception ) { if ( $ exception instanceof ModelNotFoundException ) { $ model = explode ( '\\' , $ exception -> getModel ( ) ) ; $ modelPhrase = ucwords ( implode ( ' ' , preg_split ( '/(?=[A-Z])/' , end ( $ model ) ) ) ) ; return response ( ) -> json ( [ 'error' => \ App :: make ( $ exception -> getModel ( ) ) -> modelNotFoundMessage ?? $ modelPhrase . ' not found' ] , 404 ) ; } return parent :: render ( $ request , $ exception ) ; }
Render an exception into an HTTP response.
Render an exception into an HTTP response .