1. Go to this page and download the library: Download tomatophp/filament-invoices library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use TomatoPHP\FilamentInvoices\Facades\FilamentInvoices;
use TomatoPHP\FilamentInvoices\Services\Contracts\InvoiceFor;
use TomatoPHP\FilamentInvoices\Services\Contracts\InvoiceFrom;
public function boot()
{
FilamentInvoices::registerFor([
InvoiceFor::make(Account::class)
->label('Account')
]);
FilamentInvoices::registerFrom([
InvoiceFrom::make(Company::class)
->label('Company')
]);
}
use TomatoPHP\FilamentInvoices\Services\Templates\TemplateFactory;
use TomatoPHP\FilamentInvoices\Contracts\InvoiceTemplateInterface;
// In your service provider boot method
TemplateFactory::register('my-custom', MyCustomTemplate::class);
use TomatoPHP\FilamentInvoices\Contracts\InvoiceTemplateInterface;
use TomatoPHP\FilamentInvoices\Services\Templates\AbstractTemplate;
class MyCustomTemplate extends AbstractTemplate
{
public function getName(): string
{
return 'my-custom';
}
public function getLabel(): string
{
return 'My Custom Template';
}
public function getDescription(): string
{
return 'A custom invoice template';
}
public function getViewPath(): string
{
return 'my-package::templates.custom';
}
}
use TomatoPHP\FilamentInvoices\Services\PdfGenerator;
$pdfGenerator = app(PdfGenerator::class);
// Generate PDF content
$pdfContent = $pdfGenerator->generate($invoice, 'modern');
// Stream to browser
return $pdfGenerator->stream($invoice, 'classic');
// Download file
return $pdfGenerator->download($invoice, 'professional');
use TomatoPHP\FilamentInvoices\Mail\InvoiceMail;
use Illuminate\Support\Facades\Mail;
Mail::to('[email protected]')->send(new InvoiceMail(
invoice: $invoice,
template: 'modern',
cc: '[email protected]',
subject: 'Your Invoice #{uuid}',
body: 'Dear {customer_name}, please find your invoice attached.'
));