### Install laravel-hubspot via Composer Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Installs the laravel-hubspot package via Composer. ```bash composer require jeffersongoncalves/laravel-hubspot ``` -------------------------------- ### Get form submissions and marketing emails Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Fetches form submissions for a given form GUID and lists marketing emails with a limit. ```php $submissions = Hubspot::formSubmissions('form-guid'); $emails = Hubspot::marketingEmails(['limit' => 10]); ``` -------------------------------- ### Create a deal Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Creates a new deal with the specified properties. ```php $deal = Hubspot::deals()->create([ 'dealname' => 'New Deal', 'amount' => '10000', 'dealstage' => 'appointmentscheduled', 'pipeline' => 'default', ]); ``` -------------------------------- ### Configure hubspot.php Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Configuration file for the package. Allows overriding the token, base URL, and retry settings via environment variables. ```php // config/hubspot.php return [ 'token' => env('HUBSPOT_TOKEN', ''), 'base_url' => env('HUBSPOT_BASE_URL', 'https://api.hubapi.com'), 'retry_times' => env('HUBSPOT_RETRY_TIMES', 3), 'retry_delay' => env('HUBSPOT_RETRY_DELAY', 1000), ]; ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Runs the test suite for the package. Use this command to execute all tests defined in the project. ```bash composer test ``` -------------------------------- ### Publish hubspot-config file Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Publishes the package configuration file to the application's config directory. ```bash php artisan vendor:publish --tag=hubspot-config ``` -------------------------------- ### Create a contact Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Creates a new contact with the given properties. The created contact's ID is available in the response. ```php $contact = Hubspot::contacts()->create([ 'email' => 'user@example.com', 'firstname' => 'John', 'lastname' => 'Doe', 'company' => 'Example Inc', ]); // $contact['id'] ``` -------------------------------- ### List contacts with all() Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Lists contacts with a limit of 10. The result array contains the records under the 'results' key. ```php use JeffersonGoncalves\Hubspot\Facades\Hubspot; $result = Hubspot::contacts()->all(['limit' => 10]); // $result['results'] ``` -------------------------------- ### Associate and read deal contacts Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Associates a deal with a contact using the 'deal_to_contact' association type, then retrieves the associated contacts. ```php Hubspot::deals()->associate($deal['id'], 'contacts', $contact['id'], 'deal_to_contact'); $contacts = Hubspot::deals()->associations($deal['id'], 'contacts'); ``` -------------------------------- ### Find a contact by ID Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Finds a contact by ID and selects specific properties. The returned contact's properties are accessible via the 'properties' key. ```php $contact = Hubspot::contacts()->find('101', ['email', 'firstname', 'lastname']); // $contact['properties']['email'] ``` -------------------------------- ### Set HUBSPOT_TOKEN in .env Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Sets the private app token in the .env file. Create the token under Settings > Integrations > Private Apps and grant the CRM scopes you need. ```env HUBSPOT_TOKEN=your-private-app-token ``` -------------------------------- ### Search contacts by single property Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Searches contacts by a single property (email) and selects specific properties. This is the common case for simple searches. ```php $result = Hubspot::contacts()->searchBy('email', 'user@example.com', properties: ['email', 'firstname']); ``` -------------------------------- ### Update a contact Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Updates an existing contact by ID with the provided property values. ```php Hubspot::contacts()->update('101', [ 'lifecyclestage' => 'customer', ]); ``` -------------------------------- ### Search deals with raw payload Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Searches deals using a raw payload for complex queries, including filter groups, sorting, and limit. ```php $result = Hubspot::deals()->search([ 'filterGroups' => [[ 'filters' => [ ['propertyName' => 'dealstage', 'operator' => 'EQ', 'value' => 'appointmentscheduled'], ['propertyName' => 'amount', 'operator' => 'GT', 'value' => '5000'], ], ]], 'sorts' => [['propertyName' => 'closedate', 'direction' => 'DESCENDING']], 'limit' => 50, ]); ``` -------------------------------- ### List custom object records Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Lists records from a custom CRM object type using the crm() method. ```php $result = Hubspot::crm('p_subscriptions')->all(); ``` -------------------------------- ### Handle HubspotException Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Catches HubspotException thrown on non-2xx responses and logs the error message along with the decoded error body. ```php use JeffersonGoncalves\Hubspot\Exceptions\HubspotException; try { Hubspot::contacts()->find('unknown-id'); } catch (HubspotException $e) { logger()->error($e->getMessage(), $e->errorBody()); } ``` -------------------------------- ### Delete a contact Source: https://github.com/jeffersongoncalves/laravel-hubspot/blob/main/README.md Deletes a contact by ID. ```php Hubspot::contacts()->delete('101'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.