Postingan lainnya
Cara Insert Multiple Data di Laravel gimana
jadi saya mau insert multiple data dari laravel, kan klo pake perintah insert biasa yg keambil cuman 1 data doang. gimana ya gan caranya?
controller insert
public function lapbulanandetailinsert(Request $request)
{
DB::table('lap_detail')->insert([
'full_name' => $request->full_name,
'customer_code' => $request->customer_code,
'telepon' => $request->telepon,
'alamat_cus' => $request->alamat_cus,
'unique_code' => $request->unique_code,
'payment_no' => $request->payment_no,
'tenor' => $request->tenor,
'date' => $request->date,
'keterangan' => $request->keterangan,
'cabang' => $request->cabang,
'total_bruto' => $request->total_bruto,
'total_pokok' => $request->total_pokok,
]);
return redirect('/periode');
}
0
1 Jawaban:
<div>Format datanya array dalam array<br><br></div><pre>$data = [ ['user' => value1, 'body' => anotherValue1], // record 1 ['user' => value2, 'body' => anotherValue2], // record 2 ];
Model::insert($data);</pre>
1