5

I am using Laravel 5 to generate a PDF from a subscription generated from Cashier. The docs say this is as simple as calling:

return $user->downloadInvoice($invoice->id, [
    'vendor'  => 'Your Company',
    'product' => 'Your Product',
]);

Unfortunately I'm getting an odd error:

No hint path defined for [cashier]

The code I am actually using is as follows:

Route::get('billing/invoices/download/{id}', function($id){
    $user = Auth::user();
    //$invoice = $user->invoices()->find($id);
    return $user->downloadInvoice($id, [
        'vendor'  => 'Certify Me',
        //'product' => $invoice->lines->data[0]['plan']->name,
        'product' => 'Subscription',
    ]);
});

The docs make me assume that the PDF is automatically generated. I'd then assume I could override the PDF layout if I chose to.

Mike
  • 8,767
  • 8
  • 49
  • 103
  • I am on Laravel 4.2 and the invoices are simply html. Even though the documentation states: "Use the downloadInvoice method to generate a PDF download of the invoice. Yes, it's really this easy:" – chickenchilli Jun 01 '15 at 06:05
  • It's definitely a PDF on 5. The code is referencing some PDF libs too – Mike Jun 01 '15 at 09:26

2 Answers2

3

I just ran into this (L5.1, Cashier 6.0). This seems to be caused by the service provider not being correctly loaded.

Here is how I fixed it:

  1. Check that you have added the correct service provider, at the time of writing that is Laravel\Cashier\CashierServiceProvider to your config/app.php
  2. If it still doesn't work, go run php artisan config:clear to make sure that the service provider is picked up.

Happy invoicing!

0

I'm going to resurrect this beast.

I had a similar issue because the service provider was not loaded. If you checkout CashierServiceProvider you'll see it adds the necessary 'namespace' for the 'cashier' prefixed views.

public function boot()
{
    $this->loadViewsFrom(__DIR__.'/../../views', 'cashier');

    $this->publishes([
        __DIR__.'/../../views' => base_path('resources/views/vendor/cashier'),
    ]);
}

Add Laravel\Cashier\CashierServiceProvider to your config/app.php file and inside the providers key.

For anyone who runs across this like we did.

asafreedman
  • 572
  • 4
  • 10