PHP code example of szunisoft / laravel-unas

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

    

szunisoft / laravel-unas example snippets


 
return [
    
    // ....
    
    'events' => [
    
        // Add or remove events here.
        SzuniSoft\Unas\Laravel\Events\EndpointBlacklisted::class
    
    ]
];

 
function anyFunction (SzuniSoft\Unas\Internal\Client $client) {
}


$client = app(SzuniSoft\Unas\Internal\Client::class);
$client = app('unas.client');


$builder = app(SzuniSoft\Unas\Laravel\Support\ClientBuilder::class);
$builder = app('unas.client.builder');

$client = $builder
    // Apply premium authentication API key manually.
    ->withPremium('SomeApiKey')
    // Apply legacy authentication credentials manually.
    ->withLegacy('Username', 'Password', 'ShopID', 'AuthCode')
    // Override default base path to access Unas.
    // You should never set base url manually except when url changed.
    ->basePath('http://new.domain')
    // Set events that should be fired instead throwing as exception.
    ->allowedEvents(...)
    // Set events that should not be fired. Instead exception should be thrown.
    ->disallowedEvents(...)
    // Finally retrieve the client.
    ->build();


$factory = app(SzuniSoft\Unas\Laravel\Support\ClientFactory::class);
$factory = app('unas.client.factory');

$config = [
    // Custom client configurations..
];

$client = $factory->create($config);



/** @var SzuniSoft\Unas\Internal\Client $client */
$client->getProducts()
    ->statusBase(...)
    ->parent(...)
    ->id(...)
    ->sku(...)
    ->timeStart(...)
    ->timeEnd(...)
    ->dateStart(...)
    ->dateEnd(...)
    ->contentType(...)
    ->contentParam(...)
    ->chunk(function (Illuminate\Support\Collection $products) {
        
        $products->each(function (SzuniSoft\Unas\Model\Product $product) {
            // Process product.
        });
        
    }, $perPage = 50);



/** @var SzuniSoft\Unas\Internal\Client $client */
$client->getProducts()
    ->paginate(50)
    ->page(1);

php artisan vendor:publish --provider="SzuniSoft/Unas/Laravel/UnasServiceProvider" --tag=config