sandervanhooft / laravel-invoicable

Easy invoice creation for Laravel
https://www.sandervanhooft.com/blog/laravel/stop-creating-your-laravel-invoices-manually/
MIT License
146 stars 38 forks source link

View invoice throws an error #14

Closed rabol closed 5 years ago

rabol commented 5 years ago

Hi

when trying to render a invoice like this:

$so = SalesOder::find(1); $invoice = $so->invoices()->first(); return view('vendor.invoicable.receipt')->withInvoice($invoice);

I get the following error:

Undefined variable: moneyFormatter (View: /home/vagrant/code/xxxx/resources/views/vendor/invoicable/receipt.blade.php)

sandervanhooft commented 5 years ago

Hi @rabol ,

Thanks for submitting this issue.

You can use the view() method on the Invoice for this.

If you want to implement this behavior on your own, take a look at the method's contents:

https://github.com/sandervanhooft/laravel-invoicable/blob/5e7121bc5c18534f41b805e435d0b438e13f2c3c/src/Invoice.php#L77-L86

rabol commented 5 years ago

Problem is that the view() on the invoice use a not so nice layout and I wanted to use my own.

and the view() method does not allow one to parse a view as argument.

But I got it working

sandervanhooft commented 5 years ago

If you publish the receipt view (I don't look like the current looks either... ;) ) you can adapt it to your needs, while having the benefit of using the default Invoice methods.

sandervanhooft commented 5 years ago

I'll close this issue for now, thanks for following up. Let me know if it needs to be reopened.