I've a form which can be saved to database multiple times depending upon number of entries in to it. To be precise, I have 4 input fields and after filling all the fields I click on Add button. Upon clicking on Add button, I'm creating an entry in a table row inside <form> tag like,
<form>
<table>
<tr>
<td> <input type="hidden" name="a[]" value="xyz" /> xyz</td>
<td> <input type="hidden" name="b[]" value="123" /> 123</td>
<td> <input type="hidden" name="c[]" value="456" /> 456</td>
<td> <input type="hidden" name="d[]" value="abc" /> abc</td>
</tr>
<tr>
<td> <input type="hidden" name="a[]" value="xyz" /> xyz</td>
<td> <input type="hidden" name="b[]" value="123" /> 123</td>
<td> <input type="hidden" name="c[]" value="456" /> 456</td>
<td> <input type="hidden" name="d[]" value="abc" /> abc</td>
</tr>
</table>
</form>
Now I want to save each row of the table into database as a row. I'm unable to understand how to do that. I'm getting the data in controller using dd($a = $request->input('a')); for a single field as,
array:2 [▼
0 => "xyz"
1 => "xyz"
]
I'm using this to save it into DB using Laravel,
$save=Model::Create(array(
'a'=>$request->input('a'),
'b'=>$request->input('b'),
'c'=>$request->input('c'),
'd'=>$request->input('d')
));
I'm getting error,
Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given, called in /var/www/html/quoting/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php on line 681 and defined
How can I save it into the database using the Laravel command.?