Courses

Creating CRM with Filament 3: Step-By-Step

Generate Quote PDF

You're reading a FREE PREVIEW of a PREMIUM course.
Summary of this lesson:
- Implementing PDF generation for quotes
- Creating quote preview interface
- Adding PDF download functionality
- Customizing PDF templates and formatting

Link to the repository

[Only for premium members]

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 17 lessons of this course? (97 min read)

You also get:

  • 76 courses
  • Premium tutorials
  • Access to repositories
  • Private Discord