I have the following route:
Route::get('/category/{category}/keyword/{keyword}', 'CategoryController@search');
In my controller I am trying to retrieve both the URL params using the following code:
public function search(Request $request)
{
$request->all();
...
}
The above code doesn't return the value of parameters.
If I call the following code, I get the value:
$request->category
Can someone tell me what am I doing wrong?
Thanks!
Try this:
public function search($category, $keyword)
or this:
public function search(Request $request, $category, $keyword)
If you need the Request object.
The route parameters are injected in the funcion call, they are not in the request inputs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.