PHP code example of cnrp / laravel-invoicer

1. Go to this page and download the library: Download cnrp/laravel-invoicer 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/ */

    

cnrp / laravel-invoicer example snippets




return [
    'node_binary' => env('NODE_BINARY', 'node'), // Path to the Node.js executable
    'default_theme'=> 'css/invoice-clean.php',   // Path to the default invoice theme
];

  NODE_BINARY="C:\\Program Files\\nodejs\\node.exe"
  

  NODE_BINARY="/usr/local/bin/node"
  

use CNRP\InvoicePackage\Invoice;

// Add here whatever is nessescary, remove variables that are not ebp',
        'title' => 'INVOICE',
        'invoice_number' => 'INV-0001',
        'date' => '19/06/2024',
        'from' => [
            'name' => 'Jord Heyes Hair',
            'phone' => '0987654321',
            'email' => '[email protected]',
            'address_line_1' => '1234 Street Name',
            'address_line_2' => 'Suite 567',
            'address_line_3' => 'City, State, ZIP',
        ],
        'to' => [
            'name' => 'Jane Doe',
            'phone' => '0987654321',
            'email' => '[email protected]',
            'address_line_1' => '5678 Client St',
            'address_line_2' => 'Apt 910',
            'address_line_3' => 'Client City, State, ZIP',
        ],
        'description' => 'Invoice for services rendered',
        'payment_terms' => 'Payment is due within 30 days.',
        'payment_details' => 'Account Number/Sort Code: 12345678 / 12-34-56',
        'footer' => 'See you soon!',
        'is_paid' => true,
    ],
    // Items can be added as an array here.
    [
        ['name' => 'Service 1', 'quantity' => 2, 'price' => 50],
        ['name' => 'Product A', 'description' => 'High quality product', 'quantity' => 1, 'price' => 30],
        ['name' => 'Consultation', 'price' => 100]
    ]
);

// Alternatively to add items you can call upon the addItem method on the Invoice
$invoice->addItem([
  'name' => 'Booking Deposit',
  'Move Date' => '2024-07-19',
  'price' => 150,
]);


// Generate the PDF & Download
return $invoice->generateAndDownloadPdf();

bash
php artisan vendor:publish --provider="CNRP\InvoicePackage\InvoiceServiceProvider" --tag=invoice