Hi @gauravs456 ,
The better way to get your expected output is to use joins. The example of the same is given below:
$result = User::select( "users.id", "users.name", "order.name as order_name" ) ->leftJoin("orders", "orders.userid", "=", "users.id") ->get();
select `users`.`id`, `users`.`name`, `orders`.`name` as `order_name` from `users` left join `orders` on `orders`.`userid` = `users`.`id`;
Hope this helps you in getting your expected output.
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us