lundi 6 janvier 2020

Finding result against a user_id on the basis of two booleans laravel

I have a table 'orders' from which I want to fetch data against a 'user_id' on the basis of two booleans namely ('is_paid' and 'is_cancelled'). The result will fetch me all orders of a 'user_id' which are either 'is_paid = true' or 'is_cancelled = true'. Here is my query. $query = orders::select('id','user_id','order_amount','created_date_and_time','order_address', 'is_cancelled','is_paid') ->Where('user_id', '=', $user_id) ->Where('is_paid', '=', true) ->orWhere('is_cancelled') ->get(); The query operates perfectly but it also gives me orders when i pass id of a user who does not have orders in is_paid, is_cancelled = true state. The orWhere condition always give result even if an id of a user with no orders is passed. Any help will really be appreciated TIA.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire