title: No query results for model in Laravel with Dingo - how to make a RESTful response on failure?
body: <p>I'm creating an API with Laravel based on the <a href="https://github.com/dingo/api" rel="nofollow">Dingo API</a>.</p>
  
  <p>In my routes, I have:</p>
  
  <pre><code>Route::api('v1', function () {
      Route::resource('object', 'My\Namespace\MyController');
  });
  </code></pre>
  
  <p>And in MyController:</p>
  
  <pre><code>class MyController extends \Illuminate\Routing\Controller {
  
      use Dingo\Api\Routing\ControllerTrait;
  
      public function index() {
          return MyObject::all();
      }
  
      public function show($id) {
          return MyObject::findOrFail($id);
      }
  
  }
  </code></pre>
  
  <p>This means that <code>api.domain.com/object</code> calls <code>MyController@index</code>, which works. Since there are no items in the database, this then outputs an empty json array <code>[]</code>. </p>
  
  <p><code>api.domain.com/object/123</code> calls <code>MyController@show(123)</code>. This is according to <a href="https://github.com/dingo/api/wiki/Responses" rel="nofollow">https://github.com/dingo/api/wiki/Responses</a>. However, since there are no results in the database, I get:</p>
  
  <pre class="lang-none prettyprint-override"><code>No query results for model [My\Namespace\MyObject].
  </code></pre>
  
  <p><strong>I would expect this to give a nice RESTful error instead. How do I do that?</strong></p>
  
  <p>The code of MyObject is nothing special, it's an empty class which extends <code>Illuminate\Database\Eloquent\Model</code>.</p>
  
  <p>I'm using Laravel 4.2; 5 is not supported by Dingo yet.</p>