title: How to call ApiResource with middleware in my routes?
body: <p>When I use <code>middleware</code> like below, no problem:</p>
  
  <pre><code>Route::middleware('auth:api')-&gt;get('/user', function (Request $request) {
      return $request-&gt;user();
  });
  </code></pre>
  
  <p>But if I try to use it with <code>apiResources</code>, like below:</p>
  
  <pre><code>Route::apiResources([
      'user' =&gt; 'API\UserController',
      'posts' =&gt; 'API\PostController'
  ])-&gt;middleware('auth:api');
  </code></pre>
  
  <p>Then I get an error message:</p>
  
  <blockquote>
    <p>php artisan route:list</p>
    
    <p>BadMethodCallException </p>
    
    <p>Method Illuminate\Routing\RouteRegistrar::apiResources does not
    exist.</p>
  </blockquote>
  
  <p>What is the correct way to call <code>ApiResource</code> with <code>middleware</code> in <code>routes/api.php</code> ?</p>