I working on laravel 5.1. I was stuck on figuring how to store my 2 arrays input into the same row on DB. I only know how to store for one array.
$amount[] = $request->amount;
$receipt[] = $request->receipt;
foreach ($amount as $key => $value) {
$reimbursement_item = ReimbursementItem::create([
'user_id' => $user->id,
'amount' => $value,
]);
}
DB structure and aspect result:
id user_id amount receipt
-- ------- ------ --------------
1 32 40.00 /images/r1.jpg
2 24 60.00 /images/r2.jpg
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire