I'm trying to update multiple rows but I face an array to string conversion error. Donation to Donation Items is a one-to-many relation and up to 5 types of items may be updated. I've already tried using solution from Update multiple rows of database in Laravel and used the saveMany() method but I'm still not able to update the given rows.
Here's what I tried:
$n = 0;
$donationItems = DonationItems::where('donation_id', $donationId)->get();
foreach ($donationItems as $item) {
$itemName = $r->get('item-name');
$itemQuantity = $r->get('item-quantity');
$item->name = $itemName;
$item->quantity = $itemQuantity;
$item->donation_id = $donation->id;
$donation->donationItems()->save($item);
$n += 1;
}
var_dump($item)inside yourforeach?