laravel中的搜索引擎无法正常工作+功能

时间:2015-01-04 10:57:24

标签: php html laravel

所以这是我的控制器:

    class PostsController extends BaseController
{
    public function postSearch()
    {
    $q = Input::get('username');

    $posts = DB::table('users')->whereRaw(
        "MATCH(username) AGAINST(? IN BOOLEAN MODE)",
        array($q)
    )->get();

    return View::make('posts.index', compact('users'));

}

} 和我的路线:

Route::get('posts/index', function()
{
    return View::make('posts/index');
});


Route::post('posts/index', array('as' => 'posts.index','uses' => 'PostsController@postSearch'));

和我的HTML:

<div class="search">
    {{ Form::model(null, array('route' => array('posts.index'))) }}
    {{ Form::text('username', null, array( 'placeholder' => 'Search query...' )) }}
    {{ Form::submit('Search') }}
    {{ Form::close() }}


</div>

问题是它给我错误:

MethodNotAllowedHttpException

所以我希望用户能够在索引页面中搜索并在表格的diffiere页面中给出结果如何使结果显示以及这是什么错误

0 个答案:

没有答案