so i have a form that sends a post request to a controller with the search query entered, this returns a paginated list of games that match the query, except since its a post request pagination wont work. so i changed the form to send the query as a get request i changed the route and controller but it only made a 404 not found error and didnt even get to the controller, id like to have additional filtering with this so obviously a get request would be preferred but it just wouldnt work.
the original setup:
the form:
<form method="POST" action="{{ url('/search/games') }}">
@csrf
<input type="text" class="form-control" id="fname" name="query" placeholder="Search">
</form>
the route:
Route::controller(GamesController::class)->group(function () {
Route::post('/search/games', 'search')->name('search.games');
});
the controller:
public function search(Request $request)
{
dd($request->input('query'));
}
the get setup that returned a 404 error:
the form:
<form method="GET" action="{{ url('/search/games') }}">
<input type="text" class="form-control" id="fname" name="query" placeholder="Search">
</form>
the route:
Route::controller(GamesController::class)->group(function () {
Route::get('/search/games/{query}', 'search')->name('search.games');
});
the controller:
public function search($query)
{
dd($query); //it didnt even get here
}
i also tried any:
Route::controller(GamesController::class)->group(function () {
Route::get('/products/games/{orientation?}', 'games') ->name("games");
Route::get('/product/games/{product_id}', 'game') ->name("game");
Route::any('/search/games/', 'search')->name('search.games');
});