sander-van-hooft/laravel-invoicable
Composer 安装命令:
composer require sander-van-hooft/laravel-invoicable
包简介
Easy invoice generation using Laravel Eloquent
README 文档
README
Easy invoice creation for Laravel. Unlike Laravel Cashier, this package is payment gateway agnostic.
If you're looking for Mollie payment processing, be sure to check out laravel-payable-redirect-mollie.
Structure
database/
resources
src/
tests/
vendor/
Install
Via Composer
$ composer require sander-van-hooft/laravel-invoicable
You can publish the migration with:
$ php artisan vendor:publish --provider="SanderVanHooft\Invoicable\InvoicableServiceProvider" --tag="migrations"
After the migration has been published you can create the invoices and invoice_lines tables by running the migrations:
$ php artisan migrate
Optionally, you can also publish the invoicable.php config file with:
$ php artisan vendor:publish --provider="SanderVanHooft\Invoicable\InvoicableServiceProvider" --tag="config"
This is what the default config file looks like:
return [ 'default_currency' => 'EUR', 'default_status' => 'concept', 'locale' => 'nl_NL', ];
If you'd like to override the design of the invoice blade view and pdf, publish the view:
$ php artisan vendor:publish --provider="SanderVanHooft\Invoicable\InvoicableServiceProvider" --tag="views"
You can now edit receipt.blade.php in <project_root>/resources/views/invoicable/receipt.blade.php to match your style.
Usage
Money figures are in cents!
Add the invoicable trait to the Eloquent model which needs to be invoiced (typically an Order model):
use Illuminate\Database\Eloquent\Model; use SanderVanHooft\Invoicable\IsInvoicable\IsInvoicableTrait; class Order extends Model { use IsInvoicableTrait; // enables the ->invoices() Eloquent relationship }
Now you can create invoices for an Order:
$order = Order::first(); $invoice = $order->invoices()->create([]); // To add a line to the invoice, use these example parameters: // Amount: // 121 (€1,21) incl tax // 100 (€1,00) excl tax // Description: 'Some description' // Tax percentage: 0.21 (21%) $invoice = $invoice->addAmountInclTax(121, 'Some description', 0.21); $invoice = $invoice->addAmountExclTax(100, 'Some description', 0.21); // Invoice totals are now updated echo $invoice->total; // 242 echo $invoice->tax; // 42 // Set additional information (optional) $invoice->currency; // defaults to 'EUR' (see config file) $invoice->status; // defaults to 'concept' (see config file) $invoice->receiver_info; // defaults to null $invoice->sender_info; // defaults to null $invoice->payment_info; // defaults to null $invoice->note; // defaults to null // access individual invoice lines using Eloquent relationship $invoice->lines; $invoice->lines(); // Access as pdf $invoice->download(); // download as pdf (returns http response) $invoice->pdf(); // or just grab the pdf (raw bytes) // Handling discounts // By adding a line with a negative amount. $invoice = $invoice->addAmountInclTax(-121, 'A nice discount', 0.21); // Or by applying the discount and discribing the discount manually $invoice = $invoice->addAmountInclTax(121 * (1 - 0.30), 'Product XYZ incl 30% discount', 0.21); // Convenience methods Invoice::findByReference($reference); Invoice::findByReferenceOrFail($reference); $invoice->invoicable() // Access the related model
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email info@sandervanhooft.com instead of using the issue tracker.
Credits
- Sander van Hooft
- All Contributors
- Inspired by Laravel Cashier's invoices.
License
The MIT License (MIT). Please see License File for more information.
sander-van-hooft/laravel-invoicable 适用场景与选型建议
sander-van-hooft/laravel-invoicable 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.07k 次下载、GitHub Stars 达 145, 最近一次更新时间为 2017 年 06 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payments」 「invoice」 「laravel」 「eloquent」 「SanderVanHooft」 「invoicable」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sander-van-hooft/laravel-invoicable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sander-van-hooft/laravel-invoicable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sander-van-hooft/laravel-invoicable 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dealing with payments through the Egyptian payment gateway PayMob
Librería para la gestión sencilla de pagos mediante TPV Redsys y Paypal
Laravel MPdf : Easily generate PDF files with arabic support
Szamlazz.hu integration for Laravel
Modern PHP 8.3+ BOLT 11 Lightning Network invoice encoder/decoder
Alfabank REST API integration
统计信息
- 总下载量: 12.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 147
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-06-21