Php 将输入查询添加到搜索函数Laravel Scout的路由值

Php 将输入查询添加到搜索函数Laravel Scout的路由值,php,mysql,laravel,search,laravel-scout,Php,Mysql,Laravel,Search,Laravel Scout,正在尝试设置产品的基本搜索功能。我在排序route参数变量和将查询字符串传递给搜索函数时遇到问题 Route::get('/search/{query?}', 'ProductController@searchable'); 当我手动输入查询时,它工作并返回一个查询 控制器 public function searchable($query) { // search database, with result, list on page, with links to products,

正在尝试设置产品的基本搜索功能。我在排序route参数变量和将查询字符串传递给搜索函数时遇到问题

Route::get('/search/{query?}', 'ProductController@searchable');
当我手动输入查询时,它工作并返回一个查询

控制器

public function searchable($query)
{
    // search database, with result, list on page, with links to products,
    $products = Product::search($query)->get();

    return view('search.index', compact('products'));
}
但是,我希望它来自URL
/search?test

我的表格显示:

{{ Form::open(array('action' => 'ProductController@searchable', 'method' => 'get', 'files' => 'false')) }}
<input type="search" name="search" placeholder="type keyword(s) here" />
<button type="submit" class="btn btn-primary">Search</button>
{{ Form::close() }}`
{{Form::open(数组('action'=>)ProductController@searchable“,”方法“=>”获取“,”文件“=>”假“)}
搜寻
{{Form::close()}}`

我是拉雷维尔的新手,需要一些帮助。我用的是Laravel Scout和TNTSearch

您不需要使用
{wildcard}
进行搜索。我们对此有
请求

Route::get('search', 'ProductController@searchable');
改为传递url

{{ Form::open(array('url' => 'search', 'method' => 'GET', 'files' => 'false')) }}
    <input type="search" name="search" placeholder="type keyword(s) here" />
    <button type="submit" class="btn btn-primary">Search</button>
{{ Form::close() }}

谢谢你,我在玩请求对象,我只是没有得到正确的链等等,一切都很好
public function searchable(Request $request)
{
    // search database, with result, list on page, with links to products,
    $products = Product::search($request->search)->get();

    return view('search.index', compact('products'));
}