Thank you for your response, @dalma To clarify, what I am saying is that before the request hits my controller the search parameter is completely stripped off so in my code below there is no value with the key search in the request variable. What I would like to figure out is how to make sure the search parameter stays on during the whole life of the request (which it should do naturally right?)?
public function index(Request $request)
{
$searchTerm = $request->query('search');
if ($searchTerm) $result = ListingsController::search($searchTerm);
else $result = ListingsController::showAll();
extract($result);
return view('browse.searchTable', [
'listings' => $listings,
'queryMessage' => $queryMessage,
'rowCount' => $rowCount,
'searchButtonRedirectTo' => '/browse',
'searchBarPlaceholderText' => 'Search by Title, Author, or ISBN',
'listingButtonRedirectTo' => '/browse/',
'listingButtonName' => 'Rent'
]);
}
As a side note, I am using the show method to actually show the listing that corresponds to that id, but I am specifically asking about search which I am handling through get requests and a search parameter.
For example, if I search through my search bar that exact isbn the search parameter persists!
Wait, I think I figured it out. I should be using a hidden input to handle the query portion of the url instead of manually trying to add it! See below how I do it for the search input!
<form method="GET" action="{{$searchButtonRedirectTo}}">
<div class="form-row align-items-center" id="searchDiv">
<input autofocus class="form-control form-control-lg" type="text" placeholder="{{$searchBarPlaceholderText}}" id="searchInput" name="search" required>
<button type="submit" onclick="changeColor(this)"id="searchButton" class="btn btn-sm" style=""><i class="fas fa-search fa-2x"></i></button>
</div>
</form>