title: Using variable in laravel 4.1 Query Builder
body: <p>How can use variable in laravel query builder. Here is my code.</p>
  
  <pre><code>$role = 1;
  $user = DB::table('users')
                      -&gt;join('assigned_roles', function($join)
                      {
                          $join-&gt;on('users.id', '=', 'assigned_roles.user_id')
                               -&gt;where('assigned_roles.role_id', '=', $role );
                      })
                      -&gt;get();
  </code></pre>
  
  <p>But it return Undefined variable: role. 
  How can I solve this problem. Help me plz.</p>