PHP code example of djam90 / laravel-harvest

1. Go to this page and download the library: Download djam90/laravel-harvest 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/ */

    

djam90 / laravel-harvest example snippets


use Djam90\Harvest\HarvestService;

public function __construct(HarvestService $harvestService)
{
    $this->harvestService = $harvestService;
}

public function foo()
{
    $user = $this->harvestService->user->getCurrentUser();
}

use Harvest;

public function foo()
{
    // notice the user() is a method when using the Facade
    Harvest::user()->getCurrentUser();
}

$company = $this->harvestService->company->get();
$users = $this->harvestService->user->get();

$company = Harvest::company()->get();
$users = Harvest::user()->get();

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)

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)

get()

get($updatedSince = null, $page = null, $perPage = null)
getPage($page, $perPage = null)
getById($estimateItemCategoryId)
create($name)
update($name)
delete($estimateItemCategoryId)

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)

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)

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)

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)

get($updatedSince = null, $page = null, $perPage = null)
getPage($page, $perPage = null)
getById($invoiceItemCategoryId)
create($name)
update($name)
delete($invoiceItemCategoryId)

get($invoiceId, $updatedSince = null, $page = null, $perPage = null)
getPage($invoiceId, $page, $perPage = null)
getAll($invoiceId)
create($invoiceId, $recipients, $subject = null, $body = null, $

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)

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)

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)

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)

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)

get($page = null, $perPage = null)
getPage($page, $perPage = null)
getById($roleId)
create($name, $userIds = null)
update($roleId, $name, $userIds = null)
delete($roleId)

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)

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)

get($userId, $updatedSince = null, $page = null, $perPage = null)
getPage($userId = null, $page, $perPage = null)
getAll($userId)
getForCurrentUser($page = null, $perPage = null)

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)