Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method Illuminate\View\View::__toString() must not throw an exception #16

Closed
lstables opened this issue Dec 4, 2013 · 7 comments
Closed

Comments

@lstables
Copy link

lstables commented Dec 4, 2013

What is this issue, I installed via Composer and added the alias and service provider, as per the docs on Github, and my code in the controller looks like so:

public function pdf()
{
$data = DailyReports::all();
$pdf = PDF::loadView('reports.daily', $data);
return $pdf->download('report.pdf');
}

@barryvdh
Copy link
Owner

barryvdh commented Dec 4, 2013

Try array('data' => $data) instead of $data

@lstables
Copy link
Author

lstables commented Dec 4, 2013

Tried what you said:

public function pdf()
{
$data = DailyReports::all();
$pdf = PDF::loadView('reports.daily', array('data' => $data));
return $pdf->download('report.pdf');
}

Still same error

@barryvdh
Copy link
Owner

barryvdh commented Dec 4, 2013

And can you show the view? Have you tried a simple view, for testing?
Probably some error in your view.
Op 4 dec. 2013 21:55 schreef "Lee Stables" notifications@github.com:

Tried what you said:

public function pdf()
{
$data = DailyReports::all();
$pdf = PDF::loadView('reports.daily', array('data' => $data));
return $pdf->download('report.pdf');
}

Still same error


Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-29844498
.

@lstables
Copy link
Author

lstables commented Dec 4, 2013

Or yeah, shit! the view i used chart.js need to do a new view then I'm guessing Sorry dude for bothering you

@lstables
Copy link
Author

lstables commented Dec 4, 2013

So by creating a new view I just put in {{{ $data }}} which worked but then the pdf shows an array of data can i just do a foreach loop and put some styling to it?

@barryvdh
Copy link
Owner

barryvdh commented Dec 4, 2013

It should just work the same as a normal view. So you can use blade etc to
do a foreach as usual yes.
Op 4 dec. 2013 22:00 schreef "Lee Stables" notifications@github.com:

So by creating a new view I just put in {{{ $data }}} which worked but
then the pdf shows an array of data can i just do a foreach loop and put
some styling to it?


Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-29845020
.

@lstables
Copy link
Author

lstables commented Dec 4, 2013

Sweet, your a legend, and thanks for the super, super quick replies!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants