I have two methods in my controller.
Method Number one
public function search(Request $request)
{
$search_text = $_GET['search'];
}
This method is getting me the value entered in the search bar input via $search_text
variable.
My goal here is to use that variable in another method.
Method Number Two
public function searchFilter(Request $request)
{
$brand = $request->marque;
$disponible = $request->disponibilite;
$souscat = $request->sous_categorie;
}
I have tried using the session and __construct
but didn’t work.
2
Answers
I figure it out I used session
My Second Method
// OUTPUT
I don’t know why you need two methods for that, I think that you’re calling
searchFilter
as a post request or something like that, and in your query string you have thesearch
attribute, so you could use$request
to get all values in your url, you just need to call the actual attribute that comes from the route parameters: https://laravel.com/docs/10.x/requests#retrieving-input-via-dynamic-propertiesOr even you could use this method
$request->query('search')
to get the value for that attribute.