I have a user table and a meeting table. In the destination table, I have two user IDs (customer_id, staff_id). I want to get all appointments with the name of the client and the name of the staff.
users table id name appointments table id staff_id(user_id) customer_id(user_id) datetime
As you can see, I need to join the user table with the appointment table twice. I usually do this with internal joins .
Is it possible to do the same with the eloquent loading of Laravel with ()?
Can we do something like:
appointments::with('users' * )->get();? * Do something here to inner join users table twice, and read user1.name as staff_name, user2.name as customer_name.
This is the end result I need:
appointment_id staff_id staff_name customer_id customer_name datetime
I have another question, what is the second parameter in the following query?
User::with(array( 'post'=> function() use $region {
Thanks!
source share