Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sakshamhappy's avatar

ORM for sql query

select * from transactions where transaction_type_id in ( 3,4,5,6,25) and (credit_id = 40 or debit_id =40);

i am facing problem to write ( 3,4,5,6,25) and (credit_id = 40 or debit_id =40) " bracket query" can anyone help to write model for this query?

i have written this orm

Transaction::whereIn('transaction_type_id',array(3,4,5,6,25))->where('credit_id',$user->id)->orWhere('debit_id',$user->id)->select(['id','transaction_type_id','amount','credit_id','debit_id','created_at']);

this orm is not giving right result.

0 likes
1 reply

Please or to participate in this conversation.