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

ethar's avatar
Level 5

make another query if field have specific value

i have field named arrive_location arrive location have just two value (exist, new)

in eloquent


        $orders = Orders::select('id', 'users_id', 'arrive_location')
            ->with('users:id,fname,lname,telno')

i want if arrive_location == new, to make another query to get data


UserOrderArriveAddress::select('order_id','addresse_id');
0 likes
1 reply
Charizard's avatar

You can join your Orders table to UserOrderArriveAddress table and then add a where clause to only get the results when arrive_location == new

Please or to participate in this conversation.