1. Go to this page and download the library: Download visanduma/laravel-invoice 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/ */
visanduma / laravel-invoice example snippets
use Visanduma\LaravelInvoice\Helpers\Traits\InvoiceAble;
class Customer extends Model
{
use InvoiceAble;
...
}
$customer->invoices()->create([
'invoice_date' => now(),
'tag' => 'default' // optional. just for identification
])
// or
$invoice = Invoice::make();
$customer->attachInvoice($invoice)
// adding single value
$invoice->setExtraValue('something','and its value')
// adding multiple values at once
$invoice->setExtraValues([
'something' => '',
'another thing' => 'another value'
])
// retrieve back extra values
$invoice->getExtraValue('something') // returns 'and its value'
$invoice->addPayment(100)
$invoice->addPayment(100,'advance payment') // pay with note
$invoice->addPayment(-10) // use minus values to make deduction
// get total of paid
$invoice->paidAmount() // 190 (100 + 100 - 10)
// get payment due amount
$invoice->dueAmount()
// set flat discount amount
$invoice->setDiscount(50)
// set percentage of discount
$invoice->setDiscount('5%')
// add tax
$invoice->addTax('VAT', 12) // 12 equals to 12%
// set flat discount amount
$invoiceItem->setDiscount(50)
// set percentage of discount
$invoiceItem->setDiscount('5%')
$item = InvoiceItem::create([
'name' => 'Product one',
'price' => 100,
'qty' => 1,
])
// Set discount per item
$item->setDiscount(10) // total is 90
$item->setDiscount('50%') // total is 50
// get total amount
$item->total
//get total without discount
$item->totalWithoutDiscount()
// find invoice by invoice number
$customer->findInvoiceByNumber('INV000001')
// update invoice status
$invoice->setStatus(Invoice::STATUS_COMPLETED)
$invoice->setStatus(Invoice::STATUS_DRAFT)
$invoice->setStatus(Invoice::STATUS_SENT)
// get status
$invoice->status
// update payment status
$invoice->setPaymentStatus(Invoice::STATUS_UNPAID)
$invoice->setPaymentStatus(Invoice::STATUS_PAID)
// get paid status
$invoice->paid_status
// get invoice total without taxes & invoice discount
$invoice->getItemsTotal()
// invoice item count
$invoice->getItemCount()
// invoice due
$invoice->dueAmount()
// invoiced tax
$invoice->totalTaxAmount()
// invoice total
$invoice->total
// set invoice currency symbol
$invoice->setCurrency('Rs.') // default is $