- How do I install and set up laraveldaily/laravel-invoices in a Laravel project?
- Run `composer require laraveldaily/laravel-invoices:^4.1.1` to install the package, then execute `php artisan invoices:install` to publish assets, views, translations, and configuration. This sets up the default template and config file in your project.
- Which Laravel versions does this package support?
- The package is compatible with Laravel 9.x and 10.x. Check the [GitHub repository](https://github.com/LaravelDaily/laravel-invoices) for the latest version’s specific Laravel requirements, as major updates may introduce breaking changes.
- Can I customize the invoice PDF template beyond the default design?
- Yes, the package uses Blade templates, so you can override the default template by publishing it with `php artisan vendor:publish --tag=invoices-views` and modifying the Blade files. For advanced CSS or layout changes, ensure your design adheres to PDF rendering constraints.
- How do I handle multi-currency invoices with different tax rules?
- The package supports dynamic currency formatting and per-invoice tax overrides. Use the `setCurrency()` and `setTax()` methods on the `Invoice` builder to specify currency and tax rates. For complex tax logic, extend the `Party` or `InvoiceItem` classes to handle locale-specific rules.
- Is it possible to generate invoices asynchronously for better performance?
- Yes, you can offload PDF generation to Laravel queues by dispatching a `GenerateInvoice` job. This is ideal for high-volume scenarios. Ensure your queue worker (`queue:work`) is running to process jobs efficiently.
- Where are the generated PDF invoices stored by default, and how can I change this?
- PDFs are stored on the filesystem disk configured in Laravel’s `filesystems.php`. To change the storage location, modify the `storage.disk` setting in the `invoices.php` config file or use the `save()` method with a custom disk name.
- How do I integrate invoice generation with Laravel’s mail system?
- Use the `stream()` method to generate the PDF in memory, then attach it to a Laravel mailable using `attachData()`. Example: `$invoice->stream()->detach();` and pass the stream to `Mail::send()`. This works seamlessly with Laravel’s queueable mailers.
- Are there alternatives to this package for generating invoices in Laravel?
- Alternatives include `barryvdh/laravel-dompdf` (simpler but less feature-rich) or `spatie/pdf` (more flexible but requires manual setup). This package stands out for its built-in support for taxes, discounts, multi-currency, and Laravel integrations like queues and events.
- How can I add custom validation for invoice fields like tax rates or due dates?
- Extend the `Invoice` or `Party` classes and override validation logic. Use Laravel’s built-in validation rules (e.g., `required`, `date`, `numeric`) in your custom classes or add form requests to validate input before generating invoices.
- What should I test to ensure the package works correctly in production?
- Test edge cases like multi-currency calculations, tax overrides, and large item lists. Verify PDF generation under load (e.g., 1000+ invoices/hour) and ensure storage limits (e.g., disk space) are monitored. Use `php artisan invoices:update` to refresh templates post-installation.