How to save all rows into database using Laravel?
if click save button then save all rows:
Form code:
<!-- Modal Add Wholesale Price -->
<div class="container mt-3">
<!-- The Modal -->
<!-- <div class="modal fade" id="add-wsp"> -->
<div class="modal-dialog">
<div class="modal-content" style="width:1100px;margin-left:-300px;">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Add Wholesale Price</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<form action="" method="POST" class="shadow-lg p-4 w-f">
@csrf
<div class="modal-date">
<label>Select Date:  </label>
<input type="text" name="date" placeholder="Select Price Date" class="getdate"/>
<button type="button" name="loadform" class="btn btn-warning load-form">Load Form</button>
</div>
<div class="data" style="display:none;">
<table class="table table-bordered" id="table">
<thead class="bg-success">
<tr>
<th scope="col" class="td-size">CCode</th><th scope="col" class="td-size">CUnits</th><th scope="col" class="td-size">CName</th><th scope="col" class="td-size">Vendor 1</th><th scope="col" class="td-size">Vendor 2</th><th scope="col" class="td-size">Vendor 3</th><th scope="col" class="td-size">Vendor 4</th>
</tr>
</thead>
<tr>
<td><input type="text" name="ccode" class="td-size addrow" onclick="addrow();"></td><td><input type="text" name="cunit" class="td-size"></td><td><input type="text" name="cname" class="td-size"></td><td><input type="text" name="vendor1" class="td-size"></td><td><input type="text" name="vendor2" class="td-size"></td><td><input type="text" name="vendor3" class="td-size"></td><td><input type="text" name="vendor4" class="td-size"></td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="submit" name="save" class="btn btn-success">Save</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
Form controller:
// Controller Save Community Vendor data
function commvendordata(Request $request){
print_r($request->input());
}
Web route:
// Communitedy vender data
Route::post('/auth/admin/commvendordata',[MainController::class,'commvendordata'])->name('auth.commvendordata');
Database table screenshot:
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire