I have a HTML code as below. Every time plus button click will create another row, of class="repeat" inclusive of all its inner elements. So basically each row will have input a,b,c,d,e and f.
<div class="row no-gutters mb-3 repeat">
<div class="col-md-11">
<input name="a[]" placeholder="a" class="mr-1" type="text">
<input name="b[]" placeholder="b" class="mr-1" type="text">
<input name="c[]" placeholder="c" class="mr-1" type="text">
<input name="d[]" placeholder="d" class="mr-1" type="text">
<input name="e[]" placeholder="e" class="mr-1" type="text">
<input name="f[]" placeholder="f" type="text">
</div>
<div class="col-md-1 text-center">
<button class="btn btn-outline-success btn-sm add-more" type="button"><i class="fa fa-plus"></i></button>
</div>
</div>
My code in PHP looks like this (Using Laravel framework):
foreach($request->a as $a){
foreach($request->b as $b){
foreach($request->c as $c){
foreach($request->d as $d){
foreach($request->e as $e){
foreach($request->f as $f){
$data = [
'a' => $a, 'b' => $b, 'c' => $c, 'd' => $d, 'e' => $e, 'f' => $f
];
Abc::create([$data]);
}
}
}
}
}
}
All I need is a suggestion to improve the above PHP code. Thanks in advance. :)