title: Laravel 5.2 : Undefined Variable in WhereHas
body: <p>I get <code>undefined variable $jenis_mobil</code> exactly on <code>$q-&gt;where('name', $jenis_mobil-&gt;name)</code>        </p>
  
  <pre><code>    $jenis_mobil = Car_class::find($request-&gt;jenis_mobil);
      $dari_kota = City::find($request-&gt;dari_kota);       
  
      $vehicles = Vehicle::whereHas('car', function($q){
          $q-&gt;whereHas('car_class', function($q){
              $q-&gt;where('name', $jenis_mobil-&gt;name);
          });
      })
      -&gt;whereHas('partner', function($q) {
          $q-&gt;whereHas('kota_pool', function($q){
              $q-&gt;where('name', $dari_kota-&gt;name);
          });
      })
      -&gt;where('year', $request-&gt;tahun_mobil)
      -&gt;get();
  </code></pre>
  
  <p>Is something wrong with my code? I think because <code>$jenis_mobil</code> not passed to <code>whereHas</code></p>