- in order details table i have 2 row . When I use get() it gives 2 rows. But in foreach loop it only gives the last row.
In Controller:
$orderdetail = DB::table('order_details')->where('order_id',$eid)->get();
print_r($orderdetail);
$data =array();
foreach($orderdetail as $odetail){
$data['id'] = $odetail->product_id;
}
dd($data);
output:
following is the output
Get() result:
[0] ( [id] => 832 [product_id] => 1090 ) [1] ( [id] => 833 [product_id] => 1133 )
Foreach loop output
array:1 [▼ "id" => 1133 ]