djam90/laravel-harvest
Composer 安装命令:
composer require djam90/laravel-harvest
包简介
README 文档
README
A Laravel wrapper around the Harvest time-tracking API
General Info
- Requires Laravel 5.4 or above
- Only supports Harvest API v2
Installation Instructions
Simply run in your terminal composer require djam90/laravel-harvest
The package should automatically register the service provider.
You may need to publish the vendor config file by running php artisan vendor:publish
Usage
Add the following to your .env file:
Please note that the Harvest details must be from an Admin user
HARVEST_ACCOUNT_ID=[YOUR_ACCOUNT_ID] HARVEST_PERSONAL_ACCESS_TOKEN=[YOUR_ACCESS_TOKEN]
Import the HarvestService class into your constructor or controller methods:
use Djam90\Harvest\HarvestService; public function __construct(HarvestService $harvestService) { $this->harvestService = $harvestService; }
Then you can use it in your methods:
public function foo() { $user = $this->harvestService->user->getCurrentUser(); }
You can alternatively use the Harvest facade:
use Harvest; public function foo() { // notice the user() is a method when using the Facade Harvest::user()->getCurrentUser(); }
Available Services
The following services can be accessed either using the harvest service or the facade:
clientContact
client
company
estimateItemCategory
estimateMessage
estimate
expenseCategory
expense
invoiceItemCategory
invoiceMessage
invoicePayment
invoice
project
projectTaskAssignment
projectUserAssignment
role
task
timeEntry
userProjectAssignment
user
Example
The general syntax is as follows:
$this->harvestService->SERVICE->METHOD()
See below for examples:
$company = $this->harvestService->company->get(); $users = $this->harvestService->user->get(); $company = Harvest::company()->get(); $users = Harvest::user()->get();
Service Methods
Below is a list of available methods you can call for each service.
clientContact
get($clientId = null, $updatedSince = null, $page = null, $perPage = null) getPage($page, $perPage = null) getById($contactId) create($clientId, $firstName, $lastName = null, $title = null, $email = null, $phoneOffice = null, $phoneMobile = null, $fax = null) update(contactId, $clientId, $firstName = null, $lastName = null, $title = null, $email = null, $phoneOffice = null, $phoneMobile = null, $fax = null) delete($contactId)
client
get($isActive = null, $updatedSince = null, $page = null, $perPage = null) getPage($page, $perPage = null) getById($clientId) create($name, $isActive = null, $address = null, $currency = null) update($clientId, $name = null, $isActive = null, $address = null, $currency = null) delete($clientId)
company
get()
estimateItemCategory
get($updatedSince = null, $page = null, $perPage = null) getPage($page, $perPage = null) getById($estimateItemCategoryId) create($name) update($name) delete($estimateItemCategoryId)
estimateMessage
get($estimateId, $updatedSince = null, $page = null, $perPage = null) getPage($estimateId = null, $page, $perPage = null) getAll() create($estimateId, array $recipients, $subject = null, $body = null, $sendMeACopy = null, $eventType = null) delete($estimateId, $messageId) markDraftEstimateAsSent($estimateId) markOpenEstimateAsAccepted($estimateId) markOpenEstimateAsDeclined($estimateId) reopenClosedEstimate($estimateId) updateEstimateMessage($estimateId, $eventType)
estimate
get($clientId = null, $updatedSince = null, $from = null, $to = null, $state = null, $page = null, $perPage = null) getPage($page, $perPage = null) getById($estimateId) create($clientId, $number = null, $purchaseOrder = null, $tax = null, $tax2 = null, $discount = null, $subject = null, $notes = null, $currency = null, $issueDate = null, $lineItems = null) update($estimateId, $clientId = null, $number = null, $purchaseOrder = null, $tax = null, $tax2 = null, $discount = null, $subject = null, $notes = null, $currency = null, $issueDate = null, $lineItems = null) createLineItem($estimateId, $kind, $unitPrice, $description = null, $quantity = null, $taxed = null, $taxed2 = null) updateLineItem($estimateId, $lineItemId, $kind = null, $description = null, $quantity = null, $unitPrice = null, $taxed = null, $taxed2 = null) deleteLineItem($estimateId, $lineItemId) delete($estimateId)
expenseCategory
get($isActive = null, $updatedSince = null, $page = null, $perPage = null) getPage($page, $perPage = null) getById($expenseCategoryId) create($name, $unitName = null, $unitPrice = null, $isActive = null) update($expenseCategoryId, $name = null, $unitName = null, $unitPrice = null, $isActive = null) delete($expenseCategoryId)
expense
get($userId = null, $clientId = null, $projectId = null, $isBilled = null, $updatedSince = null, $from = null, $to = null, $page = null, $perPage = null) getPage($page, $perPage = null) getById($expenseId) create($projectId, $expenseCategoryId, $spentDate, $userId = null, $units = null, $totalCost = null, $notes = null, $billable = null, $receipt = null) update($expenseId, $projectId = null, $expenseCategoryId = null, $spentDate = null, $userId = null, $units = null, $totalCost = null, $notes = null, $billable = null, $receipt = null, $deleteReceipt = null) delete($expenseId)
invoiceItemCategory
get($updatedSince = null, $page = null, $perPage = null) getPage($page, $perPage = null) getById($invoiceItemCategoryId) create($name) update($name) delete($invoiceItemCategoryId)
invoiceMessage
get($invoiceId, $updatedSince = null, $page = null, $perPage = null) getPage($invoiceId, $page, $perPage = null) getAll($invoiceId) create($invoiceId, $recipients, $subject = null, $body = null, $includeLinkToClientInvoice = null, $attachPdf = null, $sendMeACopy = null, $thankYou = null, $eventType = null) delete($invoiceId, $messageId) markDraftInvoiceAsSent($invoiceId) markOpenInvoiceAsClosed($invoiceId) reopenClosedInvoice($invoiceId) markOpenInvoiceAsDraft($invoiceId)
invoicePayment
get($invoiceId, $updatedSince = null, $page = null,$perPage = null) getPage($invoiceId, $page, $perPage = null) getAll($invoiceId) create($invoiceId, $amount, $paidAt = null, $notes = null) delete($invoiceId, $paymentId)
invoice
get($clientId = null, $projectId = null, $updatedSince = null, $page = null, $perPage = null) getPage($page, $perPage = null) getById($invoiceId) create($clientId, $retainerId = null, $estimateId = null, $number = null, $purchaseOrder = null, $tax = null, $tax2 = null, $discount = null, $subject = null, $notes = null, $currency = null, $issueDate = null, $dueDate = null, $lineItems = null) update($invoiceId, $clientId, $retainerId = null, $estimateId = null, $number = null, $purchaseOrder = null, $tax = null, $tax2 = null, $discount = null, $subject = null, $notes = null, $currency = null, $issueDate = null, $dueDate = null, $lineItems = null) createLineItem($invoiceId, $kind, $unitPrice, $projectId = null, $description = null, $quantity = null, $taxed = null, $taxed2 = null) updateLineItem($invoiceId, $lineItemId, $kind = null, $unitPrice = null, $projectId = null, $description = null, $quantity = null, $taxed = null, $taxed2 = null) deleteLineItem($invoiceId, $lineItemId) delete($invoiceId)
project
get($isActive = null, $clientId = null, $updatedSince = null, $page = null, $perPage = null) getPage($page, $perPage = null) getById($projectId) create($clientId, $name, $isBillable, $billBy, $budgetBy, $code = null, $isActive = null, $isFixedFee = null, $hourlyRate = null, $budget = null, $notifyWhenOverBudget = null, $overBudgetNotificationPercentage = null, $showBudgetToAll = null, $costBudget = null, $costBudgetIncludeExpenses = null, $fee = null, $notes = null, $startsOn = null, $endsOn = null) update($projectId, $clientId = null, $name = null, $isBillable = null, $billBy = null, $budgetBy = null, $code = null, $isActive = null, $isFixedFee = null, $hourlyRate = null, $budget = null, $notifyWhenOverBudget = null, $overBudgetNotificationPercentage = null, $showBudgetToAll = null, $costBudget = null, $costBudgetIncludeExpenses = null, $fee = null, $notes = null, $startsOn = null, $endsOn = null) delete($projectId)
projectTaskAssignment
get($projectId, $isActive = null, $updatedSince = null, $page = null, $perPage = null) getPage($projectId, $page, $perPage = null) getAll($projectId) getById($projectId, $taskAssignmentId) create($projectId, $taskId, $isActive = null, $billable = null, $hourlyRate = null, $budget = null) update($projectId, $taskAssignmentId, $isActive = null, $billable = null, $hourlyRate = null, $budget = null) delete($projectId, $taskAssignmentId)
projectUserAssignment
get($projectId, $isActive = null, $updatedSince = null, $page = null, $perPage = null) getPage($projectId, $page, $perPage = null) getAll($projectId) getById($projectId, $userAssignmentId) create($projectId, $userId, $isActive = null, $isProjectManager = null, $hourlyRate = null, $budget = null) update($projectId, $userAssignmentId, $isActive = null, $isProjectManager = null, $hourlyRate = null, $budget = null) delete($projectId, $userAssignmentId)
role
get($page = null, $perPage = null) getPage($page, $perPage = null) getById($roleId) create($name, $userIds = null) update($roleId, $name, $userIds = null) delete($roleId)
task
get($isActive = null, $updatedSince = null, $page = null, $perPage = null) getPage($page, $perPage = null) getById($taskId) create($name, $billableByDefault = null, $defaultHourlyRate = null, $isDefault = null, $isActive = null) update($taskId, $name = null, $billableByDefault = null, $defaultHourlyRate = null, $isDefault = null, $isActive = null) delete($taskId)
timeEntry
get($userId, $clientId, $projectId, $isBilled = null, $isRunning = null, $updatedSince = null, $from = null, $to = null, $page = null, $perPage = null) getPage($userId = null, $clientId = null, $projectId = null, $page, $perPage = null) getAll($userId = null, $clientId = null, $projectId = null) getById($timeEntryId) createForDuration($projectId, $taskId, $spentDate, $userId = null, $hours = null, $notes = null, $externalReference = null) createForStartAndEndTime($projectId, $taskId, $spentDate, $userId = null, $startedTime = null, $endedTime = null, $notes = null, $externalReference = null) update($timeEntryId, $projectId = null, $taskId = null, $spentDate = null, $startedTime = null, $endedTime = null, $hours = null, $notes = null, $externalReference = null) delete($timeEntryId) restart($timeEntryId) stop($timeEntryId)
userProjectAssignment
get($userId, $updatedSince = null, $page = null, $perPage = null) getPage($userId = null, $page, $perPage = null) getAll($userId) getForCurrentUser($page = null, $perPage = null)
user
get($isActive = null, $updatedSince = null, $page = null, $perPage = null) getPage($page, $perPage = null) getCurrentUser() getById($userId) create($firstName, $lastName, $email, $telephone = null, $timezone = null, $hasAccessToAllFutureProjects = null, $isContractor = null, $isAdmin = null, $isProjectManager = null, $canSeeRates = null, $canCreateProjects = null, $canCreateInvoices = null, $isActive = null, $weeklyCapacity = null, $defaultHourlyRate = null, $costRate = null, $roles = null) update($userId, $firstName = null, $lastName = null, $email = null, $telephone = null, $timezone = null, $hasAccessToAllFutureProjects = null, $isContractor = null, $isAdmin = null, $isProjectManager = null, $canSeeRates = null, $canCreateProjects = null, $canCreateInvoices = null, $isActive = null, $weeklyCapacity = null, $defaultHourlyRate = null, $costRate = null, $roles = null) delete($userId)
djam90/laravel-harvest 适用场景与选型建议
djam90/laravel-harvest 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 104 次下载、GitHub Stars 达 7, 最近一次更新时间为 2018 年 07 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 djam90/laravel-harvest 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 djam90/laravel-harvest 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 104
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2018-07-12