app/Exceptions/Handler.php
/**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $exception
     * @return \Illuminate\Http\Response
     */
Render an exception into an HTTP response.
Render an exception into an HTTP response .
public function render($request, Exception $exception)
    {
        switch($exception){
            case ($exception instanceof ModelNotFoundException):
                  if ($request->ajax()) {
                     return response()->json(['error' => 'Not Found'], 404);
                  }
                   return response()->view('errors', [], 404);
                    break;
            case ($exception instanceof ErrorException):
                return response()->view('errors', [], 404);
                break;
           default:
               return parent::render($request, $exception);
       }
    }
public function render ( $ request , Exception $ exception ) { switch ( $ exception ) { case ( $ exception instanceof ModelNotFoundException ) : if ( $ request -> ajax ( ) ) { return response ( ) -> json ( [ 'error' => 'Not Found' ] , 404 ) ; } return response ( ) -> view ( 'errors' , [ ] , 404 ) ; break ; case ( $ exception instanceof ErrorException ) : return response ( ) -> view ( 'errors' , [ ] , 404 ) ; break ; default : return parent :: render ( $ request , $ exception ) ; } }
Render an exception into an HTTP response.
Render an exception into an HTTP response .
//echo $exception->getStatusCode(); // ajax 404 json feedback // normal 404 view page // normal 404 view page