Amalmax
1 year ago

How to print project related comments in Laravel 5.2?

Posted 1 year ago by Amalmax

I need to print my comments table comments related to each project in my Laravel application. I am using domPDF for my PDF class. This is my PDF print controller:

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');
    }
    //
}

This is my comments table structure:

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

But with this controller I get the following error message:

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

how can fix this problem?

Please sign in or create an account to participate in this conversation.