PHP code example of philharmonie / lexware-office-laravel
1. Go to this page and download the library: Download philharmonie/lexware-office-laravel 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/ */
philharmonie / lexware-office-laravel example snippets
PhilHarmonie\LexOffice\ServiceProvider::class,
use PhilHarmonie\LexOffice\Facades\Contact;
// Find a contact by ID
$contact = Contact::find('contact-id');
// List contacts with optional filters
$contacts = Contact::list(['email' => '[email protected]']);
use PhilHarmonie\LexOffice\Facades\Invoice;
// Create an invoice
$invoice = Invoice::create($data, $finalize = false);
// Find an invoice by ID
$invoice = Invoice::find('invoice-id');
use PhilHarmonie\LexOffice\Facades\Dunning;
// Create a dunning
$dunning = Dunning::create($data);
// Find a dunning
$dunning = Dunning::find('dunning-id');
// Pursue a dunning
$result = Dunning::pursue('dunning-id');
// Render dunning document
$document = Dunning::render('dunning-id');
// Download dunning file
$file = Dunning::download('dunning-id');
// Get deeplink
$link = Dunning::deeplink('dunning-id');
use PhilHarmonie\LexOffice\Builders\InvoiceBuilder;
use PhilHarmonie\LexOffice\Builders\AddressBuilder;
use PhilHarmonie\LexOffice\Builders\LineItemBuilder;
$invoice = InvoiceBuilder::make()
->timezone('Europe/Berlin')
->voucherDate(now())
->address(
AddressBuilder::make()
->name('Company Name')
->supplement('c/o John Doe')
->street('Street 123')
->city('City')
->zip('12345')
->countryCode('DE')
)
->addLineItem(
LineItemBuilder::custom()
->name('Product')
->description('Detailed description of the product')
->quantity(1)
->unitName('piece')
->unitPrice('EUR', 99.99, 19.0)
)
->addLineItem(
LineItemBuilder::text()
->name('Note')
->description('Additional context for the invoice')
)
->taxConditions('net')
->paymentConditions(
label: '10 days - 3%',
duration: 30,
discountPercentage: 3.0,
discountRange: 10
)
->shippingConditions(
date: now()->addDays(5),
type: 'delivery'
)
->title('Invoice')
->introduction('Introduction text for the invoice')
->remark('Thank you for your business!')
->toArray(); // Automatically validates the invoice data
use PhilHarmonie\LexOffice\Services\ContactService;
use PhilHarmonie\LexOffice\Services\InvoiceService;
class MyController
{
public function __construct(
private ContactService $contactService,
private InvoiceService $invoiceService
) {}
public function createInvoice()
{
$contact = $this->contactService->find('contact-id');
$invoice = $this->invoiceService->create($data);
}
}