title: How do I override a laravel resource route?
body: <p>I don't think this post <a href="https://stackoverflow.com/questions/39407032/how-do-i-override-laravel-resource-route-default-method">How do I override laravel resource route default method?</a> solves my problem. </p>
  
  <p>Normal resource route is that "index" shows all items. What I want to do is have "index" show all <strong><em>related</em></strong> items for a particular id. </p>
  
  <p>So when I select a classroom from the list, I want the index action that I'm calling, to show, as it's index function, all the people for that specific classroom. </p>
  
  <p>So I replaced the default resource route</p>
  
  <pre><code>//Route::resources(['attendees' =&gt; 'attendeesController']);
  </code></pre>
  
  <p>with</p>
  
  <pre><code>Route::resource('attendees', 'attendeesController')-&gt;names([
      'index'   =&gt; 'attendees.index',
      'store'   =&gt; 'attendees.store',
      'create'  =&gt; 'attendees.create',
      'show'    =&gt; 'attendees.evaluation',
      'update'  =&gt; 'attendees.update',
      'destroy' =&gt; 'attendees.destroy',
      'edit'    =&gt; 'attendees.edit',
  ]);
  </code></pre>
  
  <p>So in my controller, I have this:</p>
  
  <pre><code>public function index(Request $request,$id)
  {
      dd($request);
      ...
  }
  </code></pre>
  
  <p>And in my view of classrooms, on a particular classroom id I have this</p>
  
  <pre><code>&lt;a href="{{route('attendees.index', ['classroom' =&gt; $data-&gt;id])}}"&gt;{{$data-&gt;Reference}}
  </code></pre>
  
  <ul>
  <li>As far as I can see, I'm passing the parameter to the controller. </li>
  <li>And the controller is setup to expect a $id parameter</li>
  </ul>
  
  <p>So why am I getting this? I'm guessing something pretty basic, but I can't see what.</p>
  
  <pre><code>Type error: Too few arguments to function
  App\Http\Controllers\AttendeesController::index(), 
  1 passed and exactly 2 expected
  </code></pre>