How to insert array data in laravel 5.4
I have a product table and device table.
I have joined these two tables where I have selected device.id
& product.name
, now I want to insert this data into my existing device
table using device.id
.
I want to insert multiple dropdown values in my database. Can anyone tell me how can I solve this problem? Below is my Controller
Code-
foreach ($request->all() as $value)
{
$deviceById= Device::find($request->id);
if($request->destination_type == 'dealer')
{
$deviceById->destination_location=$value->dealer_id;
}else
{
$deviceById->destination_location=$value->office_id;
}
$deviceById->save();
}
flash('Device Dispatch added successfully!')->success()->important();
return redirect()->back();
from Laravel Questions and Answers https://laravelquestions.com/laravel/how-to-insert-array-data-in-laravel-5-4/
via Lzo Media
No comments:
Post a Comment