title: PHP Variable scope issue laravel
body: <pre><code>public function action_detail($orderId)
  {
      $customerWithOrderDetails = Customer::with(array('order' =&gt; function($query)
      {   global $orderId;
          $query-&gt;where('id', '=', $orderId);
      }, 'order.orderdetail', 'order.attachment'))-&gt;find(Auth::user()-&gt;id);
      return var_dump($customerWithOrderDetails);
  }
  </code></pre>
  
  <p>I am getting "variable undefined" error. Why?</p>