'laravel query builder multiple left join with multiple where clause condition from different tables
I have three tables
transactions
----------------
id
cash_id
credit_id
cash
---------------
-id
-amount
-approved
credit
--------------
- id
- amount
- type
- name
Am I able to return all transactions cash or credit using left join I tried it but it's not giving me the correct results. I want it to get all the approved cash transactions and also get all credit records.
Transactions::query('transactions as t')
->leftJoin('cash as ca','ca.id', '=', 't.cash_id')
->leftJoin('credit as cr', 'cr.id', '=', 't.credit_id')
->where('ca.approved', '=', 1);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
