newbie in laravel.
In laravel sample routing
Route::get('books/{genre}', 'controller@method');
The link would be something like this
link.com/books/crime
or link.com/books/programming
how do i do it if I want to get both genre?
if this possible is to achieve
link.com/books?genre=crime,programming
how do i write that in routes? and also how do i get the value in controller?
I have tried something like this. But I don't have any idea how to achieve it.
Route::get('books?{genre?}', 'controller@method');
Controller part
function method($fields = null) {
return jsonData;
}
Found a way but its kinda awful...
route
Route::get('books', 'controller@method');
url
link.com/books?genre=crime,programming,love,religion
method
function method() {
$array = explode(',',$_GET['fields');
//.....
return jsonData;
}