如何在Laravel 5.2中打印项目相关评论?

How to print project related comments in Laravel 5.2?

我需要在我的 Laravel 应用程序中打印与每个项目相关的评论 table 评论。我正在为我的 PDF class 使用 domPDF。这是我的 PDF 打印控制器:

class pdfController extends Controller
{
    public function getPDFFF($id){
        $comments = Comment::project($id)->get(); //line 14
        $pdf = PDF::loadView('pdf.out',['comments'=>$comments]);
        return $pdf->stream('comment.pdf');
    }
    //
}

这是我的评论table结构:

id  comments  project_id
 1    asc        1
 2    fgt        5
 3    gft        2

但使用此控制器时,我收到以下错误消息:

ErrorException in pdfController.php line 14: Non-static method App\Comment::project() should not be called statically, assuming $this from incompatible context

我该如何解决这个问题?

只需使用评论 table 中的 project_id 即可获取某个项目的评论:

$comments = Comment::where('project_id',$id)->get();