How to listen to GET param in laravel middleware

423 Views Asked by At

I'm trying to listen to simple get param (test param) in laravel middleware.
here is my code

Route::middleware('api')->get('/betshistory', function (Request $request) {

return $request->user();
});

here is my url:
http://localhost:8080/api/betshistory?test=45

i tried doing this:

    print_r($request->parameter('test'));
print_r(Route::current()->parameter('test'));
print_r($request->route()->paremeters('test'));

but i cannot catch it. what am i missing? Thanks

2

There are 2 best solutions below

0
On

Check this section of the documentation related to retreiving input.

From there you could do:

$test = $request->parameter('test');

Or, in case you want to limit the search to query parameters:

$test = $request->query('test');
0
On

that was the answer

$request->input('name');

Thanks