PHP code example of alexanderpoellmann / laravel-post-plc

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

    

alexanderpoellmann / laravel-post-plc example snippets


    'post-plc' => [
        'client-id'     => env('PLC_CLIENT_ID'),
        'org-unit-id'   => env('PLC_ORG_UNIT_ID'),
        'org-unit-guid' => env('PLC_ORG_UNIT_GUID'),
        'sandbox'       => env('PLC_SANDBOX', false),
    ],

use AlexanderPoellmann\LaravelPostPlc\Classes\Address;
use AlexanderPoellmann\LaravelPostPlc\Classes\Collo;
use AlexanderPoellmann\LaravelPostPlc\Classes\Shipment;
use AlexanderPoellmann\LaravelPostPlc\Facades\LaravelPostPlc;

$from = (new Address())
    ->id(sprintf('%05d', mt_rand(1, 10000)))
    ->name('Absender GmbH')
    ->route('Rochusmarkt')
    ->street_number('5')
    ->post_code('1030')
    ->city('Wien')
    ->country_code('AT')
    ->get();

$to = (new Address())
    ->id(sprintf('%05d', mt_rand(1, 10000)))
    ->name('Musterfirma GmbH', 'c/o Frau Maria Muster')
    ->route('Landesgerichtsstraße')
    ->street_number('1')
    ->post_code('1010')
    ->city('Wien')
    ->country_code('AT')
    ->get();

$shipment = (new Shipment())
    ->withPrinter()
    ->withNumber(sprintf('%05d', mt_rand(1, 10000)))
    ->using(PostProductCodes::PaketPremiumOesterreichB2B)
    ->from($from)
    ->to($to)
    ->parcels([
        (new Collo())->weight(0.4)->get(),
        (new Collo())->weight(5.2)->get(),
    ])->get();

LaravelPostPlc::call(ServiceMethods::ImportShipment, $shipment, true);

$object = LaravelPostPlc::toCollection();

dd($object);

bash
php artisan vendor:publish --tag="laravel-post-plc-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="laravel-post-plc-config"