Skip to content

Commit 6f279bf

Browse files
committed
Adds documentation about managing relationships
1 parent 002f6e0 commit 6f279bf

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,72 @@ $userlist->companies->delete('company-1');
9090
$userlist->companies->delete([ 'identifier' => 'company-1' ]);
9191
```
9292

93+
### Tracking Relationships
94+
95+
#### Creating & updating Relationships
96+
97+
```php
98+
$relationship = [
99+
'user' => 'user-1',
100+
'company' => 'company-1',
101+
'properties' => [
102+
'role' => 'admin'
103+
]
104+
];
105+
106+
$userlist->relationships->push($relationship);
107+
108+
$userlist->relationship($relationship); // Alias
109+
$userlist->relationships->create($relationship); // Alias
110+
```
111+
112+
This is equivalent to specifying the relationship on the user model.
113+
114+
```php
115+
$user = [
116+
'identifier' => 'user-1',
117+
'relationships' => [
118+
[
119+
'company' => 'company-1',
120+
'properties' => [
121+
'role' => 'admin'
122+
]
123+
]
124+
],
125+
];
126+
127+
$userlist->users->push($user);
128+
```
129+
130+
It's also equivalent specifying the relationship on the company model.
131+
132+
```php
133+
$company = [
134+
'identifier' => 'company-1',
135+
'relationships' => [
136+
[
137+
'user' => 'user-1',
138+
'properties' => [
139+
'role' => 'admin'
140+
]
141+
]
142+
],
143+
];
144+
145+
$userlist->companies->push($company);
146+
```
147+
148+
#### Deleting Relationships
149+
150+
```php
151+
$relationship = [
152+
'user' => 'user-1',
153+
'company' => 'company-1'
154+
]
155+
156+
$userlist->relationships->delete($relationship);
157+
```
158+
93159
### Tracking Events
94160

95161
```php

0 commit comments

Comments
 (0)