PHP code example of smart-dato / brt-documento-di-ritiro

1. Go to this page and download the library: Download smart-dato/brt-documento-di-ritiro 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/ */

    

smart-dato / brt-documento-di-ritiro example snippets


use SmartDato\BrtDocumentoDiRitiro\Data\AddressData;
use SmartDato\BrtDocumentoDiRitiro\Data\BrandingData;
use SmartDato\BrtDocumentoDiRitiro\Data\ParcelData;
use SmartDato\BrtDocumentoDiRitiro\Data\PickupData;
use SmartDato\BrtDocumentoDiRitiro\Data\ShipmentData;
use SmartDato\BrtDocumentoDiRitiro\Facades\BrtDocumentoDiRitiro;

$result = BrtDocumentoDiRitiro::document()
    ->pickup(new PickupData(
        documentNumber: 'OLP202600044200',
        documentDate: '2026-08-24',
    ))
    ->sender(new AddressData(
        personName: 'Mario Balistreri',
        street: 'Via Venezia 22',
        zipcode: '94100',
        city: 'Enna',
        countryCode: 'it',
        countryName: 'Italy',
        phone: '3476221921',
    ))
    ->branding(new BrandingData(
        termsUrl: 'www.example.com',
        sideLogoPath: '/path/to/your/side-logo.png',
    ))
    ->clientCode('0123456')
    ->addShipment(new ShipmentData(
        key: 'SHIP0001',
        deliveryAddress: new AddressData(/* ... */),
        onBehalfOf: 'Your Company',
        declaredParcelCount: 2,
        parcels: [
            new ParcelData(key: 'SHIP0001X1', weight: 10.0, volume: 0.04),
            new ParcelData(key: 'SHIP0001X2', weight: 10.0, volume: 0.07),
        ],
        useBarcodeSideLayout: true,
    ))
    ->generate();

$result->documentPdf();       // corriere pages + all parcel labels, merged
$result->corrierePdf();       // corriere pages only
$result->parcelLabels();      // parcel key => label PDF (newly rendered labels)
$result->barcodes();          // parcel key => segnacollo barcode (all parcels)
$result->allocatedBarcodes(); // parcel key => BarcodeAllocation (newly allocated only)
$result->labeledParcelKeys(); // parcels that received a label in this run

$result->storeCorrierePdf('pickups/corriere.pdf')
    ->storeDocumentPdf('pickups/document.pdf')
    ->storeDocumentPdf('pickups/document.pdf', disk: 's3')
    ->storeParcelLabels(fn (string $parcelKey) => "labels/{$parcelKey}.pdf");

use SmartDato\BrtDocumentoDiRitiro\Models\SegnacolloRange;

SegnacolloRange::create([
    'from' => '10000000000010',
    'to' => '10000001000002',
    'next' => null,
]);

use SmartDato\BrtDocumentoDiRitiro\Contracts\SegnacolloAllocator;

app(SegnacolloAllocator::class)->available();

use SmartDato\BrtDocumentoDiRitiro\Data\BookingData;
use SmartDato\BrtDocumentoDiRitiro\Facades\BrtDocumentoDiRitiro;

$file = BrtDocumentoDiRitiro::bookingFile(new BookingData(
    reference: 'OLP202600044200',
    referenceLength: 15,
    clientCode: '0123456',
    exportedAt: '2026-08-21 14:30:15',
    pickupAfter: '2026-08-24 09:30:00',
    sender: new AddressData(/* ... incl. province */),
    senderStreetLines: ['Via Venezia 22'],
    weight: 21.5,
    volume: 0.113,
    parcelCount: 2,
    consignee: null, // hub or direct-delivery consignee block, blank when null
));

$file->content;  // the FNVAO record (ASCII, fixed-width)
$file->filename; // fnvao_20260821_143015#####.txt

return [
    'max_parcels' => 20,                  // BRT's per-document parcel cap
    'allocator' => [
        'connection' => null,             // connection for the range table
        'table' => 'brt_documento_di_ritiro',
    ],
    'fallback_delivery_address' => [...], // printed for non-IT destinations
    'fonts' => [...],                     // per-font file overrides (null = bundled)
    'images' => [...],                    // BRT logo/background overrides (null = bundled)
];
bash
php artisan vendor:publish --tag="brt-documento-di-ritiro-config"
bash
php artisan vendor:publish --tag="brt-documento-di-ritiro-migrations"
php artisan migrate