0
我在母版頁上有一個搜索欄。所有其他頁面正在擴展此頁面。 我有被定義爲母版頁上的搜索文本字段,例如Laravel:如何從主頁面搜索欄中搜索項目
{{Form::open(array('action'=>'[email protected]', 'method'=>'GET'))}}
{{Form::input('search', 'q', null, ['placeholder'=>'Search', 'class' => 'search'])}}
{{Form::close()}}
的routes.php文件條目如下所示:
Route::get('/searchquery/{q}', [
'uses'=> '[email protected]',
'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);
}
但是,當我執行搜索時,控制器的searchquery中的搜索查詢沒有得到正確的參數。
我的URL如下:http://localhost:8000/searchquery/%7Bq%7D?q=test
請幫助。
感謝
解決這個
我想知道如果使用查詢參數將是我前進的道路。這是我打算做的事情.. – Gagan