I tried to use POST for both route and the method of my form is POST. I'm confused it gives me an error. "The POST method is not supported for this route. Supported methods: GET, HEAD." I already inserted @csrf as recommended but still get the same error.
The code inside my form
<form action="" method="post">
@csrf
<div class="row">
<div class="col-sm-3">
<p class='mybox text-dark'><input type="checkbox" name="books[]" value="Chemistry"/>Chemistry
<input type="hidden" name="books[][name]" value="Chemistry">
<input type="number" name="books[][qty]" min="1" value="1"class="form-control">
<div class="col-sm-3">
<p class='mybox text-dark'><input type="checkbox" name="books[]" value="English"/>English
<input type="hidden" name="books[][name]" value="Chemistry">
<input type="number" name="books[][qty]" min="1" value="1"class="form-control">
<div class="text-center m-2">
<button class="btn btn-info btn-m text-center" type="submit">Submit</button>
</div>
</form>
The route
Route::post("/checkbox",[HomeController::class,"checkbox"]);
Route::post("/product",[HomeController::class,"product"]);
For my controller
public function product(Request $request){
return $request->input();
}
Aucun commentaire:
Enregistrer un commentaire