错误:未定义的属性:PostsController :: $ post

时间:2014-12-30 09:52:40

标签: php mysql laravel

我在这里遇到问题我正在尝试在我的应用程序中实现全文搜索功能

这是控制器类

<?php

class PostsController extends BaseController {

    public function postSearch(){
        $q = Input::get('query');

        $posts = $this->post->whereRaw("MATCH(instance_id,instance_type,availability_zone, status_checks,alarm_status, public_dns, key_name ) AGAINST(? IN BOOLEAN MODE)", 
            array($q))->get();

        return View::make('ec2_instance.search', compact('ec2_instance'));

    }
}
?>

我只是看不出有什么问题会得到任何帮助

1 个答案:

答案 0 :(得分:0)

你在查询中犯了错误

$posts = $this->post->whereRaw(
    "MATCH(instance_id,instance_type,availability_zone, status_checks,alarm_status, public_dns, key_name ) AGAINST(? IN BOOLEAN MODE)", 
    array($q)
)->get();

应该是

$posts = Post::whereRaw(
        "MATCH(instance_id,instance_type,availability_zone, status_checks,alarm_status, public_dns, key_name ) AGAINST(? IN BOOLEAN MODE)", 
        array($q)
    )->get();

差异为$this->post->post::