consider on first query i get 2 rows and on 2nd query i get 1 row i want to 2+1 = 3 rows into a single collection so that i can have all the data here is my query
$invoices = Invoice::whereIn('user_id', $ids)->get(); //have data in column id 1 and 2 $stock = Invoice::where('customer_id' , Auth::id())->get(); // have data in column id 3 $merge = //how i can merge this?
now consider i merged both my output should be using foreach
foreach($merge as $a){ $b[] = $a->id; } dd($b);
output should be [1,2,3]
you can get the both result in one query using orWhere:
$mergedResult=Invoice::whereIn('user_id', $ids)->orWhere('customer_id' , Auth::id())->get();
1.4m articles
1.4m replys
5 comments
57.0k users