I have query:
$id = 16;
$orders = (new Order)->where(['orders.id' => $id])
->leftJoin('transactions', 'orders.id', '=', 'transactions.order_id')
->leftJoin('cards', 'cards.id', '=', 'transactions.card_id')
->orWhere('email', '=', 'aaaa@aaaa.com')
->orWhere('last4', '=', '5555')
->get();
If transactions have card everything is fine, but if card_id in transactions table is NULL error appears: "Column not found: 1054 Unknown column 'last4' in 'where clause".
How I can elegant solve this ? How to check if column "last4" exists ?
PS.
last4 is in table "cards.last4"