title: Laravel API receive JSON 404 not found
body: <p>I'm developing a Laravel 5.6 API and I'm using Resources and Collections, Route Model Binding. </p>
  
  <p>To show an item, I currently use following code in my controller:</p>
  
  <pre><code>public function show(Todo $todo)
  {
      TodoResource::withoutWrapping();
      return new TodoResource($todo);
  }
  </code></pre>
  
  <p>In the Exceptions > Handler.php I have the following:</p>
  
  <pre><code> public function render($request, Exception $exception)
      {
          // This will replace our 404 response with
          // a JSON response.
          if ($exception instanceof ModelNotFoundException) {
              return response()-&gt;json([
              'error' =&gt; 'Resource not found'
          ], 404);
          }
  
          return parent::render($request, $exception);
      }
  </code></pre>
  
  <p>This works perfectly when the item is found in the database. If the item is not in the database I get a (when using a browser):</p>
  
  <pre><code>"Sorry, the page you are looking for could not be found"
  </code></pre>
  
  <p>When using POSTMAN rest client, I'm getting </p>
  
  <pre><code>{
      "message": "No query results for model [App\\Todo].",
      "exception": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException",
      ....
      ....
  </code></pre>
  
  <p>I would like to simply retrieve a 404 error with text "Resource not found", using both a browser or POSTMAN. </p>
  
  <p><strong>* Update with Routing info *</strong></p>
  
  <p>In my api.php, I have the following:</p>
  
  <pre><code>Route::apiResource('todos', 'TodoController');
  
  Route::fallback(function () {
      return response()-&gt;json(['message' =&gt; 'Not Found!'], 404);
  });
  </code></pre>
  
  <p>In web.php, I have:</p>
  
  <pre><code>Route::Resource('todos', 'TodoController');
  </code></pre>
  
  <p>What is the best way to achieve this?  </p>