I have two merged queries and I need to sort (orderBy) by id.
$query1= DB::table('contract')->where('to_user_id',$to_user_id)->get();
$query2= DB::table('contract')->where('from_user_id',$to_user_id)->get();
$query1= $query1->merge($query2);
I tried to orderBy('id') but it ordered individualy not together.
Instead of performing 2 queries and merging them, would it be better to just pull the relevant records in 1 go?
For example:
$query1= DB::table('contract')
->where('to_user_id',$to_user_id)
->orWhere('from_user_id', $to_user_id)
->get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With