title: Route Model Binding does not work on route group in laravel
body: <p>Suppose I have these routes : </p>
  
  <pre><code>$api-&gt;group(['prefix' =&gt; 'Course'], function ($api) {
      $api-&gt;group(['prefix' =&gt; '/{course}'], function ($api) {
         $api-&gt;post('/', ['uses' =&gt; 'CourseController@course_details']);
         $api-&gt;post('Register', ['uses' =&gt; 'CourseController@course_register']);
         $api-&gt;post('Lessons', ['uses' =&gt; 'CourseController@course_lessons']);
       });
  });
  </code></pre>
  
  <p>As you can see all <code>/</code> , <code>Register</code> and <code>Lessons</code> route prefixed by a <code>course</code> required parameter.</p>
  
  <p><code>course</code> parameter is a ID of a <code>Course</code> model that I want to use for route model binding. </p>
  
  <p>But In the other hand when I want use <code>course</code> parameter for example in  <code>course_details</code> function, it returns <code>null</code>. like this :</p>
  
  <pre><code>    public function course_details (\App\Course $course)
      {
          dd($course);
      }
  </code></pre>
  
  <p>But if I use below, all things worked fine :</p>
  
  <pre><code>    public function course_details ($course)
      {
          $course =   Course::findOrFail($course);
  
          return $course;
      }
  </code></pre>
  
  <p>Seems that it can not bind model properly. </p>
  
  <p>What is Problem ?</p>
  
  <p><strong>Update :</strong></p>
  
  <p>In fact I'm using <a href="https://github.com/dingo/api" rel="nofollow noreferrer">dingo-api</a> laravel package to create an API. all routes defined based it's configuration. </p>
  
  <p>But there is an issue about route model binding where to support route model binding we must to add a middleware named <code>binding</code> to each route that need model binding. <a href="https://github.com/dingo/api/issues/1179#issuecomment-243965337" rel="nofollow noreferrer">HERE</a> is described it.</p>
  
  <p>A bigger problem that exists is when I want to add <code>binding</code> middleware to a route group, it does not work and I must add it to each of routes. </p>
  
  <p>In this case I do not know how can I solve the problem.</p>
  
  <p><strong>Solution:</strong></p>
  
  <p>After many Googling I found that :</p>
  
  <p>I found that must to add <code>bindings</code> middleware in the same route group that added <code>auth.api</code> middleware instead adding it to each sub routes separately.<br>
  means like this : </p>
  
  <pre><code>$api-&gt;group(['middleware' =&gt; 'api.auth|bindings'], function ($api) {
  });
  </code></pre>