1. Go to this page and download the library: Download codebar-ag/laravel-zammad 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/ */
/**
* Delete a user by id.
*/
(new Zammad())->user()->delete(20);
/**
* Search a user by email. If not found create a new user.
*/
$user = (new Zammad())->user()->searchOrCreateByEmail('[email protected]');
/**
* Search a user by email. If not found create a new user with custom $data
*/
$data = [
'firstname' => 'Max',
'lastname' => 'Mustermann',
'email' => '[email protected]',
];
$user = (new Zammad())->user()->searchOrCreateByEmail('[email protected]', $data);
use CodebarAg\Zammad\Facades\Zammad;
/**
* Show a list of tickets.
*/
$tickets = Zammad::ticket()->list();
/**
* Search tickets which nn';
$tickets = Zammad::ticket()->search($term);
/**
* Show a ticket by id (empty comments).
*/
$ticket = Zammad::ticket()->show(20);
/**
* Show a ticket by id with comments.
*/
$ticket = Zammad::ticket()->showWithComments(20);
/**
* Create a new ticket.
*/
$data = [
'title' => 'The application is not working',
'group' => 'Inbox',
'customer_id' => 20,
// 'customer' => '[email protected]', // or use the customer e-mail address
'article' => [
'body' => 'It just crashes if I visit the page',
'attachments' => [
[
'filename' => 'log.txt',
'data' => 'V2FzdGUgbm8gbW9yZSB0aW1lIGFyZ3Vpbmcgd2hhdCBhIGdvb2QgbWFuIHNob3VsZCBiZSwgYmUgb25l',
'mime-type' => 'text/plain'
],
],
],
];
$ticket = (new Zammad())->ticket()->create($data);
/**
* Delete a ticket by id.
*/
(new Zammad())->user()->delete(20);
use CodebarAg\Zammad\Facades\Zammad;
/**
* Show comments by ticket id
*/
$comments = Zammad::comment()->showByTicket(20);
/**
* Show a comment by id.
*/
$comment = Zammad::comment()->show(20);
/**
* Create a new comment.
*/
$data = [
'ticket_id' => 42,
'subject' => 'Login still not working',
'body' => 'Somehow the login is not working<br>Could you check that?',
'content_type' => 'text/html',
'attachments' => [
[
'filename' => 'log.txt',
'data' => 'WW91IGFyZSBhIPCfjoEgZm9yIHRoZSDwn4yN',
'mime-type' => 'text/plain',
],
],
];
$comment = (new Zammad())->comment()->create($data);
/**
* Delete a comment by id.
*/
(new Zammad())->comment()->delete(20);
use CodebarAg\Zammad\Facades\Zammad;
/**
* Show a list of objects.
*/
$objects = Zammad::object()->list();
CodebarAg\Zammad\DTO\Ticket {
+id: 32 // int
+number: 69032 // int
+customer_id: 20 // int
+group_id: 3 // int
+state_id: 1 // int
+subject: "Login is not working" // string
+comments_count: 3 // int
+updated_at: Carbon\Carbon // Carbon
+created_at: Carbon\Carbon // Carbon
+comments: Illuminate\Support\Collection // Collection|Comment[]
}
CodebarAg\Zammad\DTO\Comment {
+id: 66 // int
+type_id: 10 // int
+ticket_id: 32 // int
+sender_id: 2 // int
+sender: "Customer" // string
+subject: "App Subject" // string
+body: "We have fixed your issue! Have a great day<br><span class=\"js-signatureMarker\"></span><blockquote type=\"cite\"><div>It is not working</div></blockquote>"
+body_without_blockquote: "We have fixed your issue! Have a great day<br>"
+body_only_blockquote: "<blockquote type=\"cite\"><div>It is not working</div></blockquote>"
+content_type: "text/plain" // string
+from: "Max Mustermann" // string
+to: null // ?string
+internal: false // boolean
+created_by_id: 20 // int
+updated_by_id: 20 // int
+origin_by_id: 4 // ?int
+attachments: Illuminate\Support\Collection // Collection|Attachment[]
+updated_at: Carbon\Carbon // Carbon
+created_at: Carbon\Carbon // Carbon
}
CodebarAg\Zammad\DTO\Attachment {
+id: 313 // int
+size: 30 // int
+name: "log.txt" // string
+type: "text/plain" // string
}
return [
/*
|--------------------------------------------------------------------------
| Zammad URL
|--------------------------------------------------------------------------
|
| This URL is used to properly communicate with the Zammad REST-API for
| every request that is made. Please make sure to ken is used to authenticate with the Zammad REST-API. You
| should make sure to activate the "HTTP Token Authentication" in the
| configuration. Afterwards generate a token in your settings page.
|
*/
'token' => env('ZAMMAD_TOKEN'),
/*
|--------------------------------------------------------------------------
| HTTP Retry Values
|--------------------------------------------------------------------------
|
| If you would like HTTP client to automatically retry the request if a client or server error occurs,
| you may specify the retry values. The maximum retry value specifies the number of times the request should be attempted,
| and the retry delay value is the number of milliseconds Laravel should wait between attempts.
|
*/
'http_retry_maximum' => env('ZAMMAD_HTTP_RETRY_MAXIMUM', 3),
'http_retry_delay' => env('ZAMMAD_HTTP_RETRY_DELAY', 1500),
/*
|--------------------------------------------------------------------------
| Object reference error on delete request
|--------------------------------------------------------------------------
|
| Please note that removing data cannot be undone. Zammad will also remove references - thus potentially tickets!
| Removing data with references in e.g. activity streams is not possible via API - this will be indicated by "error":
| "Can't delete, object has references." (Status 422). This is not a bug.
| Consider using Data Privacy via UI for more control instead. https://docs.zammad.org/en/latest/api/user.html#delete
|
*/
'object_reference_error_ignore' => env('ZAMMAD_OBJECT_REFERENCE_ERROR_IGNORE', false),
'objet_reference_error' => env('ZAMMAD_OBJECT_REFERENCE_ERROR', 'Can't delete, object has references.'),
/*
|--------------------------------------------------------------------------
| Comment Object HTML Parsing
|--------------------------------------------------------------------------
|
*/
'filter_images' => true,
'filter_tables' => true,
'filter_signature_marker' => true,
'filter_signature_marker_value' => '<span class="js-signatureMarker"></span>',
'filter_data_signature' => true,
'filter_data_signature_value' => '<div data-signature="true" data-signature-id="1">',
/*
|--------------------------------------------------------------------------
| Dynamic Ticket Attributes with Casts
|--------------------------------------------------------------------------
|
| You should define a list of all your dynamic ticket attributes here to
| ensure that they are correctly converted into the native types. The
| only limitation you have is to