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,

// Find a contact by ID
$contact = app(ContactService::class)->find('contact-id');

// List contacts with optional filters
$contacts = app(ContactService::class)->list([
    'email' => '[email protected]'
]);

// Create an invoice
$invoice = app(InvoiceService::class)->create([
    // Invoice data
], $finalize = false);

// Find an invoice by ID
$invoice = app(InvoiceServiceInterface::class)->find('invoice-id');

use PhilHarmonie\LexOffice\Facades\Contact;use PhilHarmonie\LexOffice\Facades\Invoice;

// Find a contact
$contact = Contact::find('contact-id');

// List contacts
$contacts = Contact::list(['email' => '[email protected]']);

// Create an invoice
$invoice = Invoice::create($data, $finalize = false);

// Find an invoice
$invoice = Invoice::find('invoice-id');

use PhilHarmonie\LexOffice\Contracts\ClientInterface;

$client = app(ClientInterface::class);

// GET request
$response = $client->get('/contacts', ['email' => '[email protected]']);

// POST request
$response = $client->post('/invoices', ['data' => 'value']);

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();
bash
php artisan vendor:publish --tag="lexoffice-config"