Answer the question
In order to leave comments, you need to log in
Laravel how to compose leftJoin twice into same table with different parameters?
Good day,
I have the value of customer_id and agent_id in my orders table . I need to get their data from another table through leftJoin, but the problem is that customer and agent are one entity (one invited the other) and I need to get this data in 1 request by referring to one table, an example is below
Order::select('order.customer_id', 'order.agent_id')
->leftJoin('customers', 'order.customer_id', 'customers.id')
->leftJoin('customers', 'order.agent_id', 'customers.id')
->where('id', $id)->first();
Answer the question
In order to leave comments, you need to log in
Specify an alias...
Well, in general, why are relations not registered in the model so as not to engage in such garbage?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question