anteris-dev/laravel-autotask-client
Composer 安装命令:
composer require anteris-dev/laravel-autotask-client
包简介
Integrates the Autotask client into Laravel.
README 文档
README
This package bridges the Autotask client to Laravel by injecting it into the application container.
To Install
Run composer require anteris-dev/laravel-autotask-client.
To publish the configuration file, use the command php artisan vendor:publish --provider 'Anteris\Autotask\Laravel\ServiceProvider'. Now you can enter your Autotask API information in the configuration file found at config/autotask.php or preferablly, in your .env file using the keys below.
AUTOTASK_USERNAME=username
AUTOTASK_SECRET=secret
AUTOTASK_INTEGRATION_CODE=integration-code
AUTOTASK_ZONE_URL=https://example.com
To register the facade so you may use the client like this: Autotask::tickets()->findById(0) add the following line to the 'aliases' key in the Laravel file config/app.php.
'Autotask' => Anteris\Autotask\Laravel\Facade::class,
Getting Started
You can inject the Autotask client like any other class. Laravel will automatically create the client and setup your credentials whenever you need it. An example is listed below.
use Anteris\Autotask\Client as AutotaskClient; Route::get('/', function (AutotaskClient $autotask) { $ticket = $autotask->tickets()->findById(0); });
You can also setup the facade (see above) for even easier access to the client. See the example below.
Route::get('/', function () { Autotask::tickets()->findById(0); });
For more information about the client, check out the documentation over here.
WIP Section
We are currently working on a model that can be extended and interacted with like other Laravel models (relationships loaded, etc.). These models support caching the responses so requests are not constantly being made against the Autotask server. You can specify the number of seconds a response should be cached by setting the $cache_time variable on your model. By default this is set to 24 hours, settings this to 0 disables the cache.
- Note: These are not compatible with Eloquent models / relationships.
To Install
Run composer require anteris-dev/laravel-autotask-client:dev-master.
Getting Started
Create a new model by extending the Autotask model.
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
Defining Relationships
Current belongsTo() and hasMany() relationships amongst other Autotask models is supported. These are defined as shown below.
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;
anteris-dev/laravel-autotask-client 适用场景与选型建议
anteris-dev/laravel-autotask-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 69 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 09 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 anteris-dev/laravel-autotask-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 anteris-dev/laravel-autotask-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 69
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-03