hello sir @bobbybouwmann can you help me out?
Jan 11, 2016
25
Level 1
Save multiple data in database
Hy everyone, i had two fields like this and later i needed to repeat those fields so i did that with JavaScript like this
<div class="col-md-9">
<div class="form-group">
{{Form::label('_customer_name', 'Customer Name :', ['class' => 'contc p-4 icn']) }}
{{Form::email( '_customer_name', null, ['class' => 'form-control chos_bsns', 'id' => '_customer_name', 'placeholder' => 'eMail here ']) }}
</div>
</div>
<div class="col-md-12">
<div class="form-group">
{{sprintf(Form::label('_feedback', '%s',['class' => 'compny_over icn']),'Feedback recieved from customer <small>( Maximum 100 words )</small>
<span> Word Count : 6 </span>') }}
{{Form::textarea( '_Feedback', null, ['class' => 'form-control', 'id' => '_feedback', 'placeholder' => 'Information regarding service' , 'rows' => '5']) }}
</div>
</div>
</div>
{{Form::submit('Add More', ['class' => 'p3_sbmit btn btn-default primary pull-left', 'id' =>'repeat'])}}
and i was submitting the values in the data base like this earlier
[
'name'=>Input::get('_customer_name'),
'feedback'=>Input::get('_Feedback'),
'website_id'=>Input::get('website_id')
];
Testimonial::create($data);
but since i repeated it i dont know to store those in the database any ideas would be much help.
Level 29
No, assuming you are consistently creating the fields using js, i.e number of emails = number of feedbacks
for($ii = 0; $ii < count($emails) ; $ii++) {
$email = $emails[$ii];
$feedback = $feedbacks[$ii];
Testimonial::create([
'name' => $email,
'feedback'=>$feedback
]);
}
2 likes
Please or to participate in this conversation.