我的sidebar.blade.php中有一个选择框/下拉列表查看:

{!! Form::open(array('method'=>'patch','route'=>'search')) !!}
    {!! Form::select('search',$categories,null,array_merge(['class'=>'postform ts-select'],['placeholder'=>'Select Category'],['id'=>'search'],['name'=>'search'])) !!}
    <div class="row">
        <div class="col-xs-12 col-sm-4 col-md-3 col-centered" style="margin-top: 15px">
            {!! Form::submit('Search', array('class'=>'blog-read ts-button')) !!}
        </div>
    </div>
    {!! Form::close() !!}

选择框从model - > Blog.php接收其值:

public static function getCategories()
{
    return self::groupBy('category')->lists('category', 'category');
}

在BlogController.php上:

public function getIndex()
{

    $mostRecommended = \App\Blog::mostRecommended();
    $last = \App\Blog::lastPosts();
    $categories = \App\Blog::getCategories();
    //echo'<pre>';
    //dd($mostRecommended);
    return View('blog::index', array('title' => "Welcome ", 'last' => $last, 'mostRecommended' => $mostRecommended, 'categories' => $categories));

}

public function search($category)
{
    $query = Request::get('search');
    $articles = DB::table('blog')->where('category', '=', $query);
    $mostRecommended = \App\Blog::mostRecommended();
    $last = \App\Blog::lastPosts();
    $categories = \App\Blog::getCategories();

    return View('blog::index', array('title' => $query, 'articles' => $articles, 'last' => $last, 'mostRecommended' => $mostRecommended, 'categories' => $categories));
}

路线:
Route::controller('/blog', '\Serverfireteam\blog\BlogController');

//下面的行不起作用(显然)
Route::get('/blog/search',['as'=>'search','uses'=>'Serverfireteam\blog\BlogController@search']);

我的主要内容(显示的帖子列表)通过index.blade.php迭代查看为:
@foreach($last as $post)
这适用于所有博客 . 我需要使用下拉/选择框使其动态化 . 我确信我需要AJAX(但这是我的第一个项目,我很无能)

以下是我尝试过的一小部分示例:

我知道我很亲密,这是我在这里摧毁我的经验 .

我的问题:拜托,我搞砸了哪里?我在这个问题上花了好几天 .

** UPDATE Here, I updated my code to try something else; please take a look below

<div id="categories-6" class="widget widget_categories">
    <div class="title-widget"><h3>Categories</h3></div>
    <label class="screen-reader-text" for="cat">Categories</label>

    {!! Form::open(array('method'=>'patch','route'=>'search')) !!}
    {!! Form::select('search',$categories,null,array_merge(['class'=>'postform ts-select'],['placeholder'=>'Select Category'],['id'=>'search'],['name'=>'search'])) !!}
    <div class="row">
        <div class="col-xs-12 col-sm-4 col-md-3 col-centered" style="margin-top: 15px">
            {!! Form::submit('Search', array('class'=>'blog-read ts-button')) !!}
        </div>
    </div>
    {!! Form::close() !!}

</div>

Here is a script that I currently have on my index.blade.php

<script>

    $('#search').on('change', function () {
        var category = $(this).val();
        var base_url = $({!! json_encode(url('/')) !!}).val;
        $.ajax({
            url: base_url + "/blog/search/" + category,
            dataType : "json",
            success: function (data) {
                $('#inner-container').html(data.html); //here container is the wrapper of index view
            }
        });
    });
</script>

Here is an updated look at my BlogController.php

public function getIndex()
{

    $mostRecommended = \App\Blog::mostRecommended();
    $last = \App\Blog::lastPosts();
    $categories = \App\Blog::getCategories();
    //echo'<pre>';
    //dd($mostRecommended);
    return View('blog::index', array('title' => "Welcome ", 'last' => $last, 'mostRecommended' => $mostRecommended, 'categories' => $categories));

}

Lastly, the routes.php

Route::get('/blog/search/{category}', <br>
['a s'=>'search','uses'=>'Serverfireteam\blog\BlogController@search']);

Here is the error I'm receiving

ErrorException in UrlGenerationException.php line 17:

缺少[路线:搜索] [URI:博客/搜索/ {类别}]所需的参数 .
(查看:网络/振奋/供应商/ serverfireteam /博客/ src目录/视图/ sidebar.blade.php)
(查看:web / hearten / vendor / serverfireteam / blog / src / views / sidebar.blade.php)
(查看:web / hearten / vendor / serverfireteam / blog / src / views / sidebar.blade.php)