I Have a for where you can add multiple lines by click on a button and I want to store the data into the database
form inputs I didn't post the form element since I don't think I needed to show it here
<input type="text" class="form-control" name="customer[]" />
<input type="text" class="form-control" name="produce[]" />
<select class="form-control" name="task[]">
<option value=""></option>
<option value="Pick Up">Pick Up</option>
<option value="Delivery">Delivery</option>
</select>
<input type="text" class="form-control" name="units[]" />
controller code
public function createManifest(Request $request)
{
$this->validate($request, [
// validate hidden
'date_val' => 'required',
'driver_name' => 'required',
'truck_num' => 'required',
'run_num' => 'required',
// validate fields
'customer' => 'required',
'produce' => 'required',
'task' => 'required',
'units' => 'required',
]);
$manifest = new Manifest([
'user_id' => Auth::user()->id,
'date' => $request->input('date_val'),
'driver_name' => $request->input('driver_name'),
'truck_number' => $request->input('truck_num'),
'run_number' => $request->input('run_num'),
'customer_name' => $request->input('customer'),
'produce' => $request->input('produce'),
'task' => $request->input('task'),
'units' => $request->input('units'),
]);
$manifest->save();
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ilG4H2
via IFTTT
Aucun commentaire:
Enregistrer un commentaire