title: How to select only lessons which belong to a particular course in a create form using Laravel and Blade
body: <p>I have Course and Lesson models and I want to first select a Course and then only the lessons which belong to that course to be available for selection on a dropdown list.
  I have created the pivot tabla course_lesson and the relashionship works  ok.</p>
  
  <pre><code>&lt;div class="form-group"&gt;
          &lt;select name="course_id" class="browser-default custom-select"&gt;
              &lt;option selected&gt;Choose course&lt;/option&gt;
              @foreach($courses as $course)
              &lt;option value="{{$course-&gt;id}}"&gt;{{$course-&gt;title}}&lt;/option&gt;
              @endforeach
          &lt;/select&gt;
      &lt;/div&gt;
  
  
      &lt;div class="form-group"&gt;
          &lt;select name="lesson_id" class="browser-default custom-select"&gt;
              &lt;option selected&gt;Choose lesson&lt;/option&gt;
              @foreach($courses as $course)
              @foreach($course-&gt;lesson as $lesson)
  
                  &lt;option value="{{$lesson-&gt;id}}"&gt;{{$lesson-&gt;title}}&lt;/option&gt;
                  @endforeach
              @endforeach
          &lt;/select&gt;
      &lt;/div&gt;
  </code></pre>