1. Go to this page and download the library: Download spatie/laravel-harvest-sdk 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/ */
spatie / laravel-harvest-sdk example snippets
use Spatie\Harvest\Harvest;
$harvest = app(Harvest::class);
// or use the facade
use Spatie\Harvest\Facades\Harvest;
use Spatie\Harvest\Data\UserData;
use Spatie\Harvest\Facades\Harvest;
$user = Harvest::users()->me()->dto();
// Returns: UserData
use Spatie\Harvest\Data\UserData;
use Spatie\Harvest\Facades\Harvest;
$users = Harvest::users()->all()->dto();
// Returns: array<UserData>
use Spatie\Harvest\Data\ProjectData;
use Spatie\Harvest\Facades\Harvest;
$projects = Harvest::projects()->all()->dto();
// Returns: array<ProjectData>
use Spatie\Harvest\Data\TimeEntryData;
use Spatie\Harvest\Facades\Harvest;
$paginator = Harvest::timeEntries()->all(from: '2024-01-01', to: '2024-01-31');
foreach ($paginator as $timeEntries) {
// Each page returns: array<TimeEntryData>
}
// Or collect all pages
$allTimeEntries = $paginator->collect();