i am trying to insert loop data into database with laravel but it is giving the following error:
ErrorException in Grammar.php line 118: Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given, called in C:\xampp\htdocs\laravel\App\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php on line 678 and defined
View:
<input name="product_id[]" type="hidden" class="rid" value="13">
<input type="hidden" name="product_name[]" value="Popins"><input type="hidden" name="product_code[]" value="2323">
<input name="unit_price[]" type="hidden" value="170">
<input name="quantity[]" type="text" value="2" id="" >
Controller
for($i=0; $i<count($product_name);$i++){
$newSafety = new saleItems;
$newSafety->product_id = $request->unit_price;
$newSafety->sale_id = $request->unit_price;
$newSafety->product_code = $request->product_code;
$newSafety->product_name = $request->product_name;
$newSafety->quantity = $request->quantity;
$newSafety->unit_price = $request->unit_price;
$newSafety->gross_total= $request->unit_price;
$newSafety->save();
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire