承接 eric-tromas/eloquent-invoice 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

eric-tromas/eloquent-invoice

Composer 安装命令:

composer require eric-tromas/eloquent-invoice

包简介

Easy invoice generation using Laravel Eloquent

README 文档

README

Latest Version on Packagist Software License Total Downloads

Easy invoice creation for Laravel 5.4 and up. Unlike Laravel Cashier, this package is payment gateway agnostic. This package is inspired by https://github.com/sandervanhooft/laravel-invoicable, but i needed to link invoicable model to invoice lines.

Install

Via Composer

$ composer require eric-tromas/eloquent-invoice

Next, you must install the service provider if you work with Laravel 5.4:

// config/app.php
'providers' => [
    ...
    EricTromas\EloquentInvoice\EloquentInvoiceServiceProvider::class,
];

You can publish the migration with:

$ php artisan vendor:publish --provider="EricTromas\EloquentInvoice\EloquentInvoiceServiceProvider" --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 eloquentInvoice.php config file with:

$ php artisan vendor:publish --provider="EricTromas\EloquentInvoice\EloquentInvoiceServiceProvider" --tag="config"

If you'd like to override the design of the invoice blade view and pdf, publish the view:

$ php artisan vendor:publish --provider="EricTromas\EloquentInvoice\EloquentInvoiceServiceProvider" --tag="views"

You can now edit receipt.blade.php in <project_root>/resources/views/eloquentInvoice/receipt.blade.php to match your style.

Translations are ready in french and english

$ php artisan vendor:publish --provider="EricTromas\EloquentInvoice\EloquentInvoiceServiceProvider" --tag="translations"

Usage

Money figures are in cents!

Add the invoicable trait to the Eloquent model which represent an invoice line:

use Illuminate\Database\Eloquent\Model;
use EricTromas\EloquentInvoice\IsInvoicable\IsInvoicableTrait;

class Order extends Model
{
    use IsInvoicableTrait; // enables the ->invoices() Eloquent relationship
}

Now you can create invoices for an Order:

$invoice = new Invoice();

// Set additional information (optional)
$invoice->currency; // defaults to 'EUR' (see config file)
$invoice->status; // defaults to 'draft' (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

$invoice->save();

// To add a line to the invoice, use these example parameters:
$invoice = $invoice->addLine($invoicableModel, $invoicableId, $priceInCents, $description, $quantity, $tax = 0.20);

// Invoice totals are now updated
echo $invoice->total; // 242
echo $invoice->tax; // 42


// 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.

// Convenience methods
Invoice::findByReference($reference);
Invoice::findByReferenceOrFail($reference);
$invoiceLine->invoicable() // Access the related model

Security

If you discover any security related issues, please email eric.tromas@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 19
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固