Try this:
Route::get('find', function()
{
//display search page
});
Route::get('find/{name}', function($name)
{
//display search results for {name}
});
or this:
Route::get('find/{name?}', function($name = null)
{
//logic to display search form or search results
});
read more here: http://laravel.com/docs/routing#route-parameters
I use controllers Let me show you
Route::get('find/{name}', 'SearchController@search');
or can be also post
Route::post('find/{name}', 'SearchController@search');
and into controller i pass the route parameter name into the view composer
public function search($name)
{
View::composer('search', function($view)
{
$viewdata= $view->getData();
$name=$viewdata['name'];
//query here and $view->with to parse to the template
});
return View::make('search')->with('name',$name);
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community