A demonstration of generating PDFs after record creation, downloading them from a Filament panel, and sending invoices via email.
In a Filament resource, we have a simple form to enter details for the invoice.
app/Filament/Resources/Invoices/Schemas/InvoiceForm.php:
use Filament\Schemas\Schema;use Filament\Forms\Components\TextInput; public static function configure(Schema $schema): Schema{ return $schema ->components([ TextInput::make('customer_name') ->required(), TextInput::make('customer_email') ->required(), TextInput::make('product') ->required(), TextInput::make('price') ->numeric() ->required(), ]);}
Two models lifecycle events are used when a record is being creating
and created
. Within the creating
event, a serial is generated, and after the record is created
, a job to generate a PDF is dispatched.