| Install | |
|---|---|
composer require tomatophp/filament-invoices |
|
| Latest Version: | 4.0.0 |
| PHP: | ^8.2|^8.3|^8.4 |

Generate and manage your invoices / payments using multi currencies and multi types in FilamentPHP

composer require tomatophp/filament-invoices
after install your package please run this command
php artisan filament-invoices:install
finally register the plugin on /app/Providers/Filament/AdminPanelProvider.php
->plugin(\TomatoPHP\FilamentInvoices\FilamentInvoicesPlugin::make())
To enable the Invoice Settings page in the Settings Hub, use the useSettingsHub() method:
->plugin(
\TomatoPHP\FilamentInvoices\FilamentInvoicesPlugin::make()
->useSettingsHub()
)
Don't forget to publish the settings migration:
php artisan vendor:publish --tag="filament-invoices-settings-migrations"
php artisan migrate
to start use this plugin you need to allow 2 types of users or table to fill the invoices from / for after you prepare your models use this Facade class like this on your AppServiceProvider or any other service provider
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')
]);
}
after that you can use the plugin on your filament admin panel
The package comes with 5 built-in invoice templates:
You can register your own templates using the Factory pattern:
use TomatoPHP\FilamentInvoices\Services\Templates\TemplateFactory;
use TomatoPHP\FilamentInvoices\Contracts\InvoiceTemplateInterface;
// In your service provider boot method
TemplateFactory::register('my-custom', MyCustomTemplate::class);
Your custom template class must implement InvoiceTemplateInterface:
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';
}
}
You can export invoices as PDF from:
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');
Send invoices via email with PDF attachment from:
Email settings can be configured in the Invoice Settings page, including:
Use these placeholders in email subject and body:
{uuid} - Invoice number{company_name} - Your company name{customer_name} - Customer name{total} - Invoice total amount{currency} - Currency code{due_date} - Due dateuse TomatoPHP\FilamentInvoices\Mail\InvoiceMail;
use Illuminate\Support\Facades\Mail;
Mail::to('customer@example.com')->send(new InvoiceMail(
invoice: $invoice,
template: 'modern',
cc: 'accounts@company.com',
subject: 'Your Invoice #{uuid}',
body: 'Dear {customer_name}, please find your invoice attached.'
));
The Invoice Settings page (accessible via Settings Hub when enabled) allows you to configure:
you can use this Facade class to create invoice like this
\TomatoPHP\FilamentInvoices\Facades\FilamentInvoices::create()
->for(\App\Models\Account::find(1))
->from(\App\Models\Account::find(2))
->dueDate(now()->addDays(7))
->date(now())
->items([
\TomatoPHP\FilamentInvoices\Services\Contracts\InvoiceItem::make('Item 1')
->description('Description 1')
->qty(2)
->price(100),
\TomatoPHP\FilamentInvoices\Services\Contracts\InvoiceItem::make('Item 2')
->description('Description 2')
->qty(1)
->discount(10)
->vat(10)
->price(200),
])->save();
you can publish config file by use this command
php artisan vendor:publish --tag="filament-invoices-config"
you can publish views file by use this command
php artisan vendor:publish --tag="filament-invoices-views"
you can publish languages file by use this command
php artisan vendor:publish --tag="filament-invoices-lang"
you can publish migrations file by use this command
php artisan vendor:publish --tag="filament-invoices-migrations"
Checkout our Awesome TomatoPHP