<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alexgithubp / laravel-docuware-kubernetes example snippets
use CodebarAg\DocuWare\Facades\DocuWare;
/**
* Return all file cabinets.
*/
$cabinets = DocuWare::getFileCabinets();
/**
* Return all fields of a file cabinet.
*/
$fields = DocuWare::getFields($fileCabinetId);
/**
* Return all dialogs of a file cabinet.
*/
$dialogs = DocuWare::getDialogs($fileCabinetId);
/**
* Return all used values for a specific field.
*/
$values = DocuWare::getSelectList($fileCabinetId, $dialogId, $fieldName);
/**
* Return a document.
*/
$document = DocuWare::getDocument($fileCabinetId, $documentId);
/**
* Return image preview of a document.
*/
$content = DocuWare::getDocumentPreview($fileCabinetId, $documentId);
/**
* Download single document.
*/
$content = DocuWare::downloadDocument($fileCabinetId, $documentId);
/**
* Download multiple documents.
*/
$content = DocuWare::downloadDocuments($fileCabinetId, $documentIds);
/**
* Update value of a indexed field.
*/
$value = DocuWare::updateDocumentValue($fileCabinetId, $documentId, $fieldName, $newValue);
/**
* Upload new document.
*/
$document = DocuWare::uploadDocument($fileCabinetId, $fileContent, $fileName);
/**
* Upload new document with index values.
*/
use CodebarAg\DocuWare\DTO\DocumentIndex;
$indexes = collect([
DocumentIndex::make('DOCUMENT_TEXT', 'Indexed Text'),
DocumentIndex::make('DOCUMENT_NUMBER', 42),
]);
$document = DocuWare::uploadDocument(
$fileCabinetId,
$fileContent,
$fileName,
$indexes,
);
/**
* Delete document.
*/
DocuWare::deleteDocument($fileCabinetId, $documentId);
use CodebarAg\DocuWare\Facades\DocuWare;
/**
* Most basic example to search for documents. You only need to provide a valid
* file cabinet id.
*/
$id = '87356f8d-e50c-450b-909c-4eaccd318fbf';
$paginator = DocuWare::search()
->fileCabinet($id)
->get();
/**
* Search in multiple file cabinets. Provide an array of file cabinet ids.
*/
$fileCabinetIds = [
'0ee72de3-4258-4353-8020-6a3ff6dd650f',
'3f9cb4ff-82f2-44dc-b439-dd648269064f',
];
$paginator = DocuWare::search()
->fileCabinets($fileCabinetIds)
->get();
/**
* Find results on the next page.
*
* Default: 1
*/
$paginator = DocuWare::search()
->fileCabinet($id)
->page(2)
->get();
/**
* Define the number of results which should be shown per page.
*
* Default: 50
*/
$paginator = DocuWare::search()
->fileCabinet($id)
->perPage(30)
->get();
/**
* Use the full-text search. You have to activate full-text search in your file
* cabinet before you can use this feature.
*/
$paginator = DocuWare::search()
->fileCabinet($id)
->fulltext('My secret document')
->get();
/**
* Search documents which are created from the first of march.
*/
$paginator = DocuWare::search()
->fileCabinet($id)
->dateFrom(Carbon::create(2021, 3, 1))
->get();
/**
* Search documents which are created until the first of april.
*/
$paginator = DocuWare::search()
->fileCabinet($id)
->dateUntil(Carbon::create(2021, 4, 1))
->get();
/**
* Order the results by field name. Supported values: 'asc', 'desc'
*/
$paginator = DocuWare::search()
->fileCabinet($id)
->orderBy('DWSTOREDATETIME', 'desc')
->get();
/**
* Search documents filtered to the value. You can specify multiple filters.
*/
$paginator = DocuWare::search()
->fileCabinet($id)
->filter('TYPE', 'Order')
->filter('OTHER_FIELD', 'other')
->get();
/**
* You can specify the dialog which should be used.
*/
$dialogId = 'bb42c30a-89fc-4b81-9091-d7e326caba62';
$paginator = DocuWare::search()
->fileCabinet($id)
->dialog($dialogId)
->get();
/**
* You can also combine everything.
*/
$paginator = DocuWare::search()
->fileCabinet($id)
->page(2)
->perPage(30)
->fulltext('My secret document')
->dateFrom(Carbon::create(2021, 3, 1))
->dateUntil(Carbon::create(2021, 4, 1))
->filter('TYPE', 'Order')
->filter('OTHER_FIELD', 'other')
->orderBy('DWSTOREDATETIME', 'desc')
->dialog($dialogId)
->get();
use CodebarAg\DocuWare\Facades\DocuWare;
/**
* Make encrypted URL for a document in a file cabinet.
*/
$fileCabinetId = '87356f8d-e50c-450b-909c-4eaccd318fbf';
$documentId = 42;
$url = DocuWare::url()
->fileCabinet($fileCabinetId)
->document($documentId)
->make();
/**
* Make encrypted URL for a document in a basket.
*/
$basketId = 'b_87356f8d-e50c-450b-909c-4eaccd318fbf';
$url = DocuWare::url()
->basket($basketId)
->document($documentId)
->make();
/**
* Make encrypted URL valid for a specific amount of time. In the example below
* the URL is valid for one week. Afterwards the URL is no longer working.
*/
$url = DocuWare::url()
->fileCabinet($fileCabinetId)
->document($documentId)
->validUntil(now()->addWeek())
->make();
use CodebarAg\DocuWare\Facades\DocuWare;
/**
* Login with your credentials. You only need to login once. Afterwards the
* authentication cookie is stored in the cache `docuware.cookies` and is
* used for all further requests.
*/
DocuWare::login();
/**
* Logout your current session. Removes the authentication cookie in the cache.
*/
DocuWare::logout();
use CodebarAg\DocuWare\Events\DocuWareResponseLog;
// Log each response from the DocuWare REST API.
DocuWareResponseLog::class => [
//
],
return [
/*
|--------------------------------------------------------------------------
| DocuWare Credentials
|--------------------------------------------------------------------------
|
| Before you can communicate with the DocuWare REST-API it is necessary
| to enter your credentials. You should specify a url containing the
| scheme and hostname. In addition add your username and password.
|
*/
'credentials' => [
'url' => env('DOCUWARE_URL'),
'username' => env('DOCUWARE_USERNAME'),
'password' => env('DOCUWARE_PASSWORD'),
],
/*
|--------------------------------------------------------------------------
| Passphrase
|--------------------------------------------------------------------------
|
| In order to create encrypted URLs we need a passphrase. This enables a
| secure exchange of DocuWare URLs without anyone being able to modify
| your query strings. You can find it in the organization settings.
|
*/
'passphrase' => env('DOCUWARE_PASSPHRASE'),
/*
|--------------------------------------------------------------------------
| Authentication Cookie Lifetime
|--------------------------------------------------------------------------
|
| Here you may define the amount of minutes the authentication cookie is
| valid. Afterwards it will be removed from the cache and you need to
| provide a fresh one. By default, the lifetime lasts for one year.
|
*/
'cookie_lifetime' => (int) env('DOCUWARE_COOKIE_LIFETIME', 525600),
];