What we want to do
Get clean url like this
domain.com/student/query/your+search+query
domain.com/student/subject/subject-name/chapter/chapter-name
subject-name, chapter-name is parameter
domain.com/student/subject/subject-name
subject-name is a paramter
problem
how to create those urls for form get method
what we have done
using javascript right now
you can use sth like this:
Route::get('student/query/{query}', SearchController@search');
in your search controller you will then have the variable $query available like so
public function search($query) {
//do your search magic here
//and return a correct response (JSON, view,...)
}
for multiple parameters the story is similar
in routes
Route::get('student/subject/{subjectName}/chapter/{chapterName}', SubjectChapterController@show');
and then in your SubjectChapterController
public function show($subjectName, $chapterName) {
//fetch the data, return the view,...
}
what you should be a bit careful is that you place the routes in the order of most specific to more general. If i remember correctly, as soon as a match to a pattern is found the other routes are no longer checked (not 100% sure about this).