Skip to main content

Generate Quote PDF

Premium
6 min read

Now that we have our Quotes being created, we should have the ability to generate a PDF and send it to our customer:

In this lesson, we will do the following:

  • Create a view page for our Quote - this will be a page to preview PDF
  • Install and modify a PDF generation package
  • Create a controller to generate the PDF (both preview and download)

Creating a Simple View Page for Quote

We can quickly create a new View page by running the following command:

php artisan make:filament-page ViewQuote --resource=QuoteResource --type=ViewRecord

This will generate a file, but we still need to register it in our Resource:

app/Filament/Resources/QuoteResource.php

// ...
 
public static function table(Table $table): Table
{
return $table
// ...
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
])
->recordUrl(function ($record) {
return Pages\ViewQuote::getUrl([$record]);
});
}
 
public static function getPages(): array
{
return [
'index' => Pages\ListQuotes::route('/'),
'create' => Pages\CreateQuote::route('/create'),
'view' => Pages\ViewQuote::route('/{record}'),
'edit' => Pages\EditQuote::route('/{record}/edit'),
];
}

Now we can click on the row, and we should see our new page:

That's it for now. Next, we will generate the PDF and display it on the View page.


Installing PDF Package

Next, we will install a package Laravel Invoices to deal with the invoice generation itself:

Note: This can be replaced with any other package or just pure DomPDF

composer require laraveldaily/laravel-invoices:^3.1

Then, we need to publish the package files:

php artisan invoices:install

This will create...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 01 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

MR
Martin Radu ✓ Link copied!

i culd not install composer require laraveldaily/laravel-invoices:^3.0 but had success with composer require laraveldaily/laravel-invoices:^3.1

M
Modestas ✓ Link copied!

Hmm, I think I made a mistake here. Updating!

RA
Richard A. Hoyle ✓ Link copied!

yea the latest version as of 11/16/2023 is 3.2.0 and their has been a few changes such as where the file resources/lang/vendor/invoices/en/invoice.php is being named and where it is getting put I found it in resources/views/vendor/invoices/templates/default.blade.php

DL
David Lun ✓ Link copied!

well, actually package now follows laravel change, it was due

https://laravel.com/docs/9.x/upgrade#the-lang-directory

RA
Richard A. Hoyle ✓ Link copied!

Ok I am using Laravel 10.32.1; I am VERRY SORRY I was looking in the wrong file I have found the lang file in the resources NOT in the views file my bad! Found it after I tuck a brake "to many hours on the computer".

ED
Ervalsa Dwi Nanda ✓ Link copied!

yeay, finish the course

RC
Rafal Ciesielski ✓ Link copied!

I have a substantive question, why is there an Invoice and not a Quote ? The invoice is for the items sold and not for the quote

M
Modestas ✓ Link copied!

We are using an Invoice based package to generate a Quote, but not to use it as an actual invoice.

It works pretty much the same, with the only difference on what is inside and how it's given to a customer

RA
Richard A. Hoyle ✓ Link copied!

Ok doing grate up to this point however when installing the latest version 3.2.0 of laraveldaily/ laravel-invoices it is not creating the resources/lang/vendor/invoices/en/invoice.php file. So, where do we make the changes you are telling us to make in this file?

DL
David Lun ✓ Link copied!

well, actually package now follows laravel change, it was due

https://laravel.com/docs/9.x/upgrade#the-lang-directory

M
Modestas ✓ Link copied!

I'm sorry, but I'm really confused here. I checked the article, updated the package and everything still matches. I'm really not sure what you had missmatched there but it seems like it's not an issue at all.

RA
Richard A. Hoyle ✓ Link copied!

In my version of Laravel the “LANG/VENDOR” file is in its only file under the database and above the PUBLIC and I was able to fix it thanks. It appears as though Filament might have moved it and placed a lot of its files in it.

ps. I have this in a github repository if you want to see it.

M
Modestas ✓ Link copied!

I am really confused by what you just said here :) But sure, you can share the repo and I'll take a look.

VM
Victor Marcelo Farfan Gozalvez ✓ Link copied!

Some elements are useful, the steps could be more detailed, it may be understood that people already have knowledge and necessary steps and explanations are omitted. But it can be done better!

FC
Frederico Carvalho ✓ Link copied!

Thanks for your time to create this incredible course

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.