Reputation: 247
Actually I don't want to check the else
condition of below code and status 1 is compulsory only in the case of co_order_paymenttype_id is 1( both are in same table)
this is my code
DeliveryOrder::where('cb_order_type' , 0)->whereRaw('IF (`co_order_paymenttype_id` = 1,
`status` = 1,`status` = 0)')->paginate($page);
Upvotes: 0
Views: 166
Reputation: 192
Ok as I commented above if you don't need else
then it's not the case that you should use if
statment.
you shoud use only where to get your needs and to make that in laravel you need to use advanced where
DeliveryOrder::where('cb_order_type' , 0)->where(function($query){
$query->where('co_order_paymenttype_id', 1)
->where('status' = 1);
})->paginate($page);
if you need to and any other condition you need to change it as you want, you can add another orWhere
for expample.
please read the documentaion in the link above.
Upvotes: 1