PHP code example of anteris-dev / laravel-autotask-client

1. Go to this page and download the library: Download anteris-dev/laravel-autotask-client 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/ */

    

anteris-dev / laravel-autotask-client example snippets


'Autotask' => Anteris\Autotask\Laravel\Facade::class,


use Anteris\Autotask\Client as AutotaskClient;

Route::get('/', function (AutotaskClient $autotask) {

    $ticket = $autotask->tickets()->findById(0);

});



Route::get('/', function () {

    Autotask::tickets()->findById(0);

});



use Anteris\Autotask\Laravel\Models\AutotaskModel;

class Ticket extends AutotaskModel
{
    protected string $endpoint = 'Tickets'; // Must be the plural form of the endpoint
    protected int $cache_time  = 86400;     // 24 hours in seconds
}

// Supported actions:
Ticket::count(); // Used like the count in the query builder
Ticket::find();  // Array of IDs or an ID
Ticket::get(); // Used like the get in the query builder
Ticket::loop(); // Used like the loop in the query builder
Ticket::where(); // Used like the where in the query builder
Ticket::orWhere(); // Used like the orWhere in the query builder



use Anteris\Autotask\Laravel\Models\AutotaskModel;

class Contact extends AutotaskModel
{
    protected string $endpoint = 'Contacts'; // Must be the plural form of the endpoint
    protected int $cache_time  = 86400;      // 24 hours in seconds

    public function company()
    {
        return $this->belongsTo(Company::class);
    }

    public function tickets()
    {
        return $this->hasMany(Ticket::class);
    }
}

// Relationships can be referenced like normal Laravel models:
$contact = Contact::find(1);

echo $contact->company->companyName;