title: Laravel Eloquent Eager Loading : Join same table twice
body: <p>I have a <strong>users</strong> table and an <strong>appointments</strong> table. In appointment table I have two user ID's (customer_id, staff_id). I want to retrieve all the appointments with customer name and the staff name.</p>
  
  <pre><code>users table
  id
  name
  
  appointments table
  id
  staff_id(user_id)
  customer_id(user_id)
  datetime
  </code></pre>
  
  <p>As you can see, I have to join the users table twice with the appointments table.
  Usually I do this with <strong>inner joins</strong>. </p>
  
  <p>Can we do the same thing with Laravel eloquent eager loading using with()?</p>
  
  <p>Can we do something like:</p>
  
  <pre><code>appointments::with('users' * )-&gt;get();?
  * Do something here to inner join users table twice, and read user1.name as staff_name,   user2.name as customer_name.
  </code></pre>
  
  <p>This is the final output I need:</p>
  
  <pre><code>appointment_id
  staff_id
  staff_name
  customer_id
  customer_name
  datetime
  </code></pre>
  
  <p>I have another question, what is the second parameter in the following query?</p>
  
  <pre><code>User::with(array(
      'post'=&gt; function() use $region {
            //what is use $region means? Can you give me an example?
       }
  ));
  </code></pre>
  
  <p>Thanks!</p>