title: Laravel Advanced Wheres how to pass variable into function?
body: <p>Example in doc:</p>
  
  <pre><code>DB::table('users')
          -&gt;whereExists(function($query)
          {
              $query-&gt;select(DB::raw(1))
                    -&gt;from('orders')
                    -&gt;whereRaw('orders.user_id = users.id');
          })
          -&gt;get();
  </code></pre>
  
  <p>But what if I need to use external variable like that:</p>
  
  <pre><code>            -&gt;where('city_id', '=', $this-&gt;city-&gt;id)
              -&gt;where(function($query)
                  {
                      $query-&gt;where('name', 'LIKE', '%'.$searchQuery.'%')
                      -&gt;orWhere('address', 'LIKE', '%'.$searchQuery.'%')
  
                  })
  </code></pre>
  
  <p>For now I created new property and accessed it through <code>$this-&gt;</code>, but is there any more convenient way?</p>