Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to generate a Cashier PDF in Laravel

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.

like image 273
Mike Avatar asked Oct 19 '22 14:10

Mike


1 Answers

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!

like image 158
Micael Gustafsson Avatar answered Oct 24 '22 14:10

Micael Gustafsson