【发布时间】:2014-03-02 21:57:45
【问题描述】:
我的母版页上有一个搜索栏。所有其他页面都在扩展此页面。 我在母版页上有一个搜索文本字段,它是这样定义的
{{Form::open(array('action'=>'TopicsController@searchquery', 'method'=>'GET'))}}
{{Form::input('search', 'q', null, ['placeholder'=>'Search', 'class' => 'search'])}}
{{Form::close()}}
Routes.php 入口如下:
Route::get('/searchquery/{q}', [
'uses'=> 'TopicsController@searchquery',
'as' => 'topic.searchquery']);
控制器动作看起来像这样
public function searchquery($q)
{
if($search = Request::get('q')){
$topics = Topic::search($search);
}
else {
$topics = Topic::all();
}
$categories = Category::all();
$tags = $this->topicRepo->allTags();
return View::make('topics.topicSearch')->withCategories($categories)->withTopics($topics)->with('term', $q)->withTags($tags);
}
但是,当我执行搜索时,控制器的搜索查询中的搜索查询没有得到正确的参数。
我的网址如下所示:http://localhost:8000/searchquery/%7Bq%7D?q=test
请帮忙。
谢谢
【问题讨论】: