Reputation: 4896
i have a query where I come across this
left join `product_term_batch` as `ptb` on `ptb`.`batch_id` = `o`.`batch_id` and `ptb`.`product_id` = `o`.`product_id`
Piece of code how to convert into Laravel LeftJoin() function
Edit1
I know to write this
->leftJoin('product_term_batch as `ptb`',' `ptb`.`batch_id`','=',' `o`.`order_id`')
But what about the and part ?
Thanks & regards
Upvotes: 1
Views: 32
Reputation: 50798
You can pass a closure function to the leftJoin
method, and inside of it, chain your ->on()
->leftJoin(function($join){
$join->on('product_term_batch as ptb', 'ptb.batch_id', '=', 'o.order_id')
->on('ptb.product_id', '=', 'o.product_id`');
});
Furthermore, your backticks
aren't necessary as you have no non-confirming characters in table or column names.
Upvotes: 1