hello everyone i'm beginner in laravel, i want to know how do i inserting a multiple value to a table like, i have an order_detail table on my database and it has order_id, product_id, price and total,
i want to insert a multiple value so i create the form like this which can be added using javascript
<?php for($x = 1;$x <=2; $x++){ ?>
{{ Form::text('', $x]) }}
{{ Form::text('pj[$x]order_id') }}
{{ Form::text('pj[$x]product_id) }}
{{ Form::text('pj[$x]price) }}
{{ Form::text('pj[$x]total) }}
{{ Form::submit('insert!') }}
<?php } ?>
and then i try something like this in my OrderDetailController
$inputs = Input::get('pj');
if(DB::table('order_detail')->insert($inputs)){
return Redirect::route('admin.order_detail.index')
->with('message','success');
}
return Redirect::back()
->with('message','something went wrong')
->withInput();
but i only get 1 value from my input which is the last one
ps: this is my first time asking question in this forum, so if you need any information feel free to ask me, and pardon for my bad English, thanks in advance!