mardi 20 septembre 2016

How to use save method with array inputs in larvel5.0

I want to save all array inputs to database using save method in laravel

HTML form

 <form>
       <input class="form-control" name="amount[]" type="text"/>
       <input class="form-control" name="price[]" type="text"/>
 </form>

I have used Javascript

var data = $('#form_A').serializeArray();

PHP

$cust = new customer();
$all_input = Request::input();
foreach($all_input as $k=>$vals) {
     $data[] = ['amount'=>$vals];
}

$cust = $data;
$cust->save();



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire