PHP code example of badchoice / handesk-php

1. Go to this page and download the library: Download badchoice/handesk-php 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/ */

    

badchoice / handesk-php example snippets


// In AppServiceProvider boot method
Handesk::setup(config('services.handesk.url'), config('services.handesk.token'));

    //In config.services.php file
    'handesk' => [
        'url'   => env('HANDESK_URL', 'http://handesk.dev/api'),
        'token' => env('HANDESK_TOKEN', 'the-api-token')
    ],

$tickets = (new Ticket)->get('requesterNameOrEmail');

$solvedTickets = (new Ticket)->get('requesterNameOrEmail','solved');
$openTickets = (new Ticket)->get('requesterNameOrEmail','solved');

$ticket_id = (new Ticket)->create(
    ["name" => "Requester name", "email" => "[email protected]"], 
    "The ticket subject", 
    "The ticket initial body", 
    ["tag1","tag2"]
   );

$ticket = (new Ticket)->find($id);
$comments = $ticket->comments; //Includes the initial comment
$comments->first()->requester; // ["name" => "Requester name", "email" => "Requester email"]

$ticket->addComment("Adding a comment");
$ticket->addComment("Adding a comment and solving the ticket", true);

    $team = Team::create("team name", "team email";
    (new Team(2))->tickets();           //gets all open tickets for team with id 2
    (new Team(2))->tickets('solved');   //gets all solved tickets for team with id 2
    (new Team(2))->ticketsCount();      //gets the count of all open tickets for team with id 2
    (new Team(2))->ticketsCount('closed'); //gets the count of all closed tickets for team with id 2
    
    (new Team(2))->leads();      //gets the open leads for a team (paginated)
    (new Team(2))->leadsCount(); //gets the count of all live leads for team with id 2

$id = (new Lead)->create([
            "email"       => "[email protected]",
            "body"        => "I'm interested in buying this awesome app",
            "username"    => "brucewayne",
            "name"        => "Bruce Wayne",
            "phone"       => "0044 456 567 54",
            "address"     => "Wayne manner",
            "city"        => "Gotham",
            "postal_code" => "90872",
            "company"     => "Wayne enterprises"]
            ,
            ["lightning","handesk"]
        );

composer