PHP code example of stechstudio / laravel-hubspot

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

    

stechstudio / laravel-hubspot example snippets


use STS\HubSpot\Crm\Contact;

$contact = Contact::find(123);

$contact = Contact::create([
    'firstname' => 'Test',
    'lastname' => 'User',
    'email' => '[email protected]'
]);

$contact = new Contact;
$contact->firstname = 'Test';
$contact->lastname = 'User';
$contact->email = '[email protected]';
$contact->save();

Contact::find(123)->update([
    'email' => '[email protected]'
]);

$contact = Contact::find(123);
$contact->email = '[email protected]';
$contact->save();

Contact::find(123)->delete();

$contacts = Contact::paginate(20);

// This will iterate over ALL your contacts!
foreach(Contact::cursor() AS $contact) {
    echo $contact->id . "<br>";
}

// This will get 100 contact records, starting at 501
$contacts = Contact::take(100)->after(500)->get();

// This will get the default 50 records, starting at the first one
$contacts = Contact::get();

Contact::where('lastname','!=','Smith')->get();

Contact::where('email', '[email protected]')->get();

Contact::where('days_to_close', 'BETWEEN', [30, 60])->get();

Contact::search('1234')->get();

Contact::orderBy('lastname')->get();

Contact::orderBy('days_to_close', 'desc')->get();

foreach(Company::find(555)->contacts AS $contact) {
    echo $contact->email;
}

Company::find(555)->contacts()
    ->where('days_to_close', 'BETWEEN', [30, 60])
    ->search('smith')
    ->get();

// This will only be two API calls, not three
Contact::with('notes')->find(123)->notes;

Company::find(555)->contacts()->create([
    'firstname' => 'Test',
    'lastname' => 'User',
    'email' => '[email protected]'
]);

Company::find(555)->contacts()->attach(Contact::find(123));

Company::find(555)->contacts()->detach(Contact::find(123));
bash
HUBSPOT_ACCESS_TOKEN=XXX-XXX-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX