This is my url -> http://localhost:82/?search=asd
How do I catch 'asd' in route?
I try this -> Route::get('/?search={SearchValue}', 'TryController@search');
But it didn't work. It won't even get into the controller.
You don't have to adjust the routes. But include $request in your controller method. Then use your request object to access it.
use Illuminate\Http\Request;
public function search(Request $request) {
// to access the query parameters
$search = $request->query->get('search');
// similar but different syntax
$search = $request->query('search');
// generic method that checks all input including query
$search = $request->input('search');
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments