Есть ли способ, которым я могу получить доступ к сводной таблице, как показано ниже ???
array:18 [
"id" => 4
"user_id" => 5
"price" => 8659
"created_at" => "2020-01-17 14:08:06"
"updated_at" => "2020-01-17 14:08:06"
"pivot" => array:5 [
"purchase_id" => 6
"product_id" => 4
"quantity" => "13"
"unit_price" => "3212"
"discount" => "11.00"
]
]
Я хочу обновить Pivot
Таблица, и я попробовал метод, как показано ниже
foreach($request->products as $product) {
$purchase->products()->updateExistingPivot($product['id'], [
'unit_price' => $product['unit_price'],
'quantity' => $product['quantity'],
'discount' => $product['discount'],
]);
// dd($product);
}
Но получил ошибку message: "Undefined index: unit_price"
.
Любая помощь, заранее спасибо ...