I access a page of Route::post('search'). From this page, I perform a form submission using a POST method. If the validation fails, I get error The GET method is not supported for this route. Supported methods: POST. probably because when Laravel validation redirects back to the same page, it redirects as a GET method.
I am unable to change nor add a new Route for search due to strict rules here. How should I redirect back to search page as POST method?
This is from CustomFormRequest.php
protected function failedValidation(Validator $validator)
{
\Log::debug("WAS HERE");
\Log::debug(print_r($this->request->all(), true));
\Log::debug(print_r($this->request->method(), true));
}
I can see the request but not the method. Meaning I cant update the method manually to try and check if this would work. Though if I check the value in controller without the formrequest, I can see both.
I tried searching for SO questions but nothing really about my concern.
How should I redirect to the same route using POST method?
The GET method is not supported for this route. Supported methods: POST.has nothing to do with the validation layer, that error is on the routing layer. You have declared a post route, but are making a get request to that route.probably because when Laravel validation redirects back to the same page, it redirects as a GET method.so you are using aPOSTrequest to load the page?so you are using a **POST** request to load the pageYes I am accessing thesearchpage using apostmethod. from here, perform apostform submission