Skip to content

Commit a97e11a

Browse files
committed
Update README with an example for detach method.
1 parent 477f975 commit a97e11a

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

README.md

+18-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Interact with HubSpot's CRM with an enjoyable, Eloquent-like developer experienc
1212
- Cursors provide a seamless way to loop through all records: `foreach(Contact::cursor() AS $contact) { ... }`
1313

1414
> **Note**
15-
> Only the CRM API is currently implemented.
15+
> Only the CRM API is currently implemented.
1616
1717
## Installation
1818

@@ -24,7 +24,7 @@ composer require stechstudio/laravel-hubspot
2424

2525
### 2) Configure HubSpot
2626

27-
[Create a private HubSpot app](https://developers.hubspot.com/docs/api/private-apps#create-a-private-app) and give it appropriate scopes for what you want to do with this SDK.
27+
[Create a private HubSpot app](https://developers.hubspot.com/docs/api/private-apps#create-a-private-app) and give it appropriate scopes for what you want to do with this SDK.
2828

2929
Copy the provided access token, and add to your Laravel `.env` file:
3030

@@ -102,8 +102,8 @@ This package provides three different ways of fetching these results.
102102

103103
#### Paginating
104104

105-
Similar to a traditional database paginated result, you can paginate through a HubSpot collection of objects.
106-
You will receive a `LengthAwarePaginator` just like with Eloquent, which means you can generate links in your UI just like you are used to.
105+
Similar to a traditional database paginated result, you can paginate through a HubSpot collection of objects.
106+
You will receive a `LengthAwarePaginator` just like with Eloquent, which means you can generate links in your UI just like you are used to.
107107

108108
```php
109109
$contacts = Contact::paginate(20);
@@ -113,8 +113,8 @@ By default, this `paginate` method will look at the `page` query parameter. You
113113

114114
#### Cursor iteration
115115

116-
You can use the `cursor` method to iterate over the entire collection of objects.
117-
This uses [lazy collections](https://laravel.com/docs/9.x/collections#lazy-collections) and [generators](https://www.php.net/manual/en/language.generators.overview.php)
116+
You can use the `cursor` method to iterate over the entire collection of objects.
117+
This uses [lazy collections](https://laravel.com/docs/9.x/collections#lazy-collections) and [generators](https://www.php.net/manual/en/language.generators.overview.php)
118118
to seamlessly fetch chunks of records from the API as needed, hydrating objects when needed, and providing smooth iteration over a limitless number of objects.
119119

120120
```php
@@ -129,7 +129,7 @@ foreach(Contact::cursor() AS $contact) {
129129
130130
#### Manually fetching chunks
131131

132-
Of course, you can grab collections of records with your own manual pagination or chunking logic.
132+
Of course, you can grab collections of records with your own manual pagination or chunking logic.
133133
Use the `take` and `after` methods to specify what you want to grab, and then `get`.
134134

135135
```php
@@ -143,7 +143,7 @@ $contacts = Contact::get();
143143
### Searching and filtering
144144

145145
When retrieving multiple objects, you will frequently want to filter, search, and order these results.
146-
You can use a fluent interface to build up a query before retrieving the results.
146+
You can use a fluent interface to build up a query before retrieving the results.
147147

148148
#### Adding filters
149149

@@ -185,7 +185,7 @@ Contact::search('1234')->get();
185185

186186
#### Ordering
187187

188-
You can order the results with any property.
188+
You can order the results with any property.
189189

190190
```php
191191
Contact::orderBy('lastname')->get();
@@ -199,7 +199,7 @@ Contact::orderBy('days_to_close', 'desc')->get();
199199

200200
### Associations
201201

202-
HubSpot associations are handled similar to Eloquent relationships.
202+
HubSpot associations are handled similar to Eloquent relationships.
203203

204204
#### Dynamic properties
205205

@@ -230,7 +230,7 @@ Normally, there are three HubSpot API calls to achieve the above result:
230230
2. Retrieve all the contact IDs that are associated to this company
231231
3. Query for contacts that match the IDs
232232

233-
Now we can eliminate the second API call by eager loading the associated contact IDs.
233+
Now we can eliminate the second API call by eager loading the associated contact IDs.
234234
This library always eager-loads the IDs for associated companies, contacts, deals, and tickets. It does not eager-load
235235
IDs for engagements like emails and notes, since those association will tend to be much longer lists.
236236

@@ -258,7 +258,13 @@ This will create a new contact, associate it to the company, and return the new
258258
You can also associate existing objects using `attach`. This method accepts and ID or an object instance.
259259

260260
```php
261-
Company::find(555)->attach(Contact::find(123));
261+
Company::find(555)->contacts()->attach(Contact::find(123));
262+
```
263+
264+
You can also detach existing objects using `detach`. This method accepts and ID or an object instance.
265+
266+
```php
267+
Company::find(555)->contacts()->detach(Contact::find(123));
262268
```
263269

264270

0 commit comments

Comments
 (0)