PHP code example of volldigital / laravel-ntlm

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

    

volldigital / laravel-ntlm example snippets


composer 

php artisan vendor:publish --provider="VOLLdigital\LaravelNavision\LaravelNavisionServiceProvider"

$client = app(VOLLdigital\LaravelNavision\Client::class);


$client = app(VOLLdigital\LaravelNavision\Client::class);

$data = $client->fetchCollection("Events");

$event = $client->fetchOne("Events", 'Key', 'Number');



$client = app(VOLLdigital\LaravelNavision\Client::class);

// file will be stored in /storage/app/temp/curl_uniqueid.temp

$data = $client->fetchCollection("Events", true);



$client = app(VOLLdigital\LaravelNavision\Client::class);

if ($client->ping() === false) {
    throw new RunTimeException('No connection available');
}


$client->writeData(
    'Items',
    [
        'Item_Code' => 'VD',
        'Item_Description' => 'Test data'
    ]
);

dd($client->countCollection('Events')); // Outputs: 100293

$temp = $this->client->fetchCollection('Events?$skip=10000');

$temp = $this->client->fetchCollection('Events?$top=10');

    protected function fetchData(string $uri, $key, bool $chunk = false, ?callable $filter = null)
    {
        $temp = $this->client->fetchCollection($uri, $chunk);
        $data = [];

        foreach($temp as $ts) {
            if (!is_null($filter) && $filter($ts) === false) {
                continue;
            }

            $data[$ts[$key]] = $ts;
        }

        return collect($data);
    }

    protected function fetchAll()
    {
        $number = $this->client->countCollection('Events');
        $pageLimit = 10000;
        $pages = (int)ceil($number / $pageLimit);
        $events = [];

        for ($i = 0; $i < $pages; $i++) {
            $skip = $i * $pageLimit;

            $temp = $this->fetchData('Events?$skip='.$skip, 'Number');

            $events = array_merge($events, $temp->toArray());
        }

        return collect($events);
    }