1. Go to this page and download the library: Download tapp/laravel-hubspot 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/ */
tapp / laravel-hubspot example snippets
use Tapp\LaravelHubspot\Models\HubspotContact;
use Tapp\LaravelHubspot\Contracts\HubspotModelInterface;
class User extends Authenticatable implements HubspotModelInterface
{
use HubspotContact;
public array $hubspotMap = [
'email' => 'email',
'first_name' => 'first_name',
'last_name' => 'last_name',
'user_type' => 'type.name', // Supports dot notation for relations
];
}
use Tapp\LaravelHubspot\Models\HubspotCompany;
use Tapp\LaravelHubspot\Contracts\HubspotModelInterface;
class Company extends Model implements HubspotModelInterface
{
use HubspotCompany;
public array $hubspotMap = [
'name' => 'name',
'domain' => 'domain',
'industry' => 'industry',
];
}
class User extends Authenticatable implements HubspotModelInterface
{
use HubspotContact;
public function getHubspotProperties(array $map): array
{
return [
'full_name' => $this->first_name . ' ' . $this->last_name,
'display_name' => $this->getDisplayName(),
'account_age_days' => $this->created_at->diffInDays(now()),
];
}
}
use App\Models\User;
use App\Models\Company;
use Tapp\LaravelHubspot\Observers\HubspotContactObserver;
use Tapp\LaravelHubspot\Observers\HubspotCompanyObserver;
public function boot(): void
{
User::observe(HubspotContactObserver::class);
Company::observe(HubspotCompanyObserver::class);
}