Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php laravel中的搜索引擎不工作+功能_Php_Html_Laravel - Fatal编程技术网

Php laravel中的搜索引擎不工作+功能

Php laravel中的搜索引擎不工作+功能,php,html,laravel,Php,Html,Laravel,这是我的控制器: class PostsController extends BaseController { public function postSearch() { $q = Input::get('username'); $posts = DB::table('users')->whereRaw( "MATCH(username) AGAINST(? IN BOOLE

这是我的控制器:

        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('posts'));

    }


}
我的路线是:

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>
因此,我不希望用户能够在索引页面中搜索,并在表格中的diffident页面中为他们提供结果
如何显示结果?这是什么错误?

您做得很好,但在路由文件中,您的类命名为PostsController,但实际的控制器类名为postController这就是为什么它说找不到PostsController

路线:

控制器

看法


我已将我的{{Form::openarray'url'=>'login',class'=>'Form horizontal'}}更改为您所说的,但它给了我相同的错误:您是否更改了控制器类名?postController到PostsController?这是一个完全不同的故事。现在必须更改数据库表。类似这样的内容:ALTER TABLE yourtablename ADD FULLTEXT FULLTEXT_indexusername.yupe tanx帮助并清除了该错误,但我现在明白了:未找到视图[posts.index]。啊,你能显示视图文件夹目录结构吗?它必须是这样的视图->帖子->index.blade.php,然后它不会给出这个错误。
MethodNotAllowedHttpException
Route::get('posts/index', function()
{
    return View::make('posts/index');
});

Route::post('posts/index', array('as' => 'posts.index','uses' => 'PostsController@postSearch'));
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('posts'));

    }
}
<div class="search">
    {{ Form::open(array('route' => 'post.index', 'method' => 'POST', 'role' => 'search')) }}
    {{ Form::text('username',null, array( 'placeholder' => 'Search query...' )) }}
    {{ Form::submit('Search') }}
    {{ Form::close() }}
</div>

@if(isset($posts))

@foreach($posts as $post)

{{$post->id}}

@endforeach

@endif