PHP code example of byte5digital / laravel-harvest
1. Go to this page and download the library: Download byte5digital/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/ */
byte5digital / laravel-harvest example snippets
// resolve out of ioc container
$harvest = app()->make('harvest');
// getting all clients
$harvest->clients->get();
Harvest::clients()->get();
// getting a client with id of 12345
$harvest->clients->find(12345);
Harvest::clients()->find(12345);
// getting all expenses
$harvest->expenses->get();
Harvest::expenses()->get();
// getting an expense with id of 12345
$harvest->expenses->find(12345);
Harvest::expenses()->find(12345);
//... you get the idea
// get all user_assignments with the project id of 12345
$harvest->userAssignments->fromProject(12345)->get()
// get an user_assignments with the id of 12345 which belongs to the project id of 4567
$harvest->userAssignments->fromProject(4567)->find(12345)
// get all estimate messages with the estimate id of 12345
$harvest->estimateMessages->fromEstimate(12345)->get();
// get an estimate messages with the id of 12345 which belongs to the estimate id of 4567
$harvest->estimateMessages->fromEstimate(4567)->find(12345)
// receiving some response
$respose = Harvest::users()->get();
// convert result to json
$result->toJson();
// convert result to collection
$result->toCollection();
// convert result to paginated collection
$result->toPaginatedCollection();
// get results from page 10
$harvest->projects()->page(10)->get()
// limit result entries to 50
$harvest->projects()->limit(50)->get();
// limit result entries and get results from page 10
$harvest->projects()->limit(50)->page(10)->get();
// get next result page
$result = $result->next();
// get previous result page
$result = $result->previous();
// get all invoices with a state of 'draft'
$harvest->invoices()->state('draft')->get();
// get all invoices with a client_id of '123445'
$harvest->invoices()->client('123445')->get();
// get all invoices with a project_id of '123445'
$harvest->invoices()->project('123445')->get();
// get all invoices which were updated since '2018-01-12'
// => does also accept other formats like '12.01.2018'
$harvest->invoices()->updatedSince('2018-01-12')->get();
// get all invoices with an issue_date >= '2018-01-01'
$harvest->invoices()->from('2018-01-01')->get();
// get all invoices with an issue_date <= '2018-01-01'
$harvest->invoices()->to('2018-01-01')->get();
// loading all external relations of one expense model
// by default if you have enabled `uses_database` in the config
// all external relations are saved to the database.
$expense->loadExternal();
// load all external relations without saving to db
$expense->loadExternal('*', false);
// load only user and client relations
$expense->loadExternal(['user', 'client']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.