Skip to content

Commit b7e130a

Browse files
committed
Update README.md
1 parent ec5271a commit b7e130a

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

README.MD

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,56 @@ class BlogItem extends Item
149149
This package uses [Laravel Collections](https://laravel.com/docs/collections) as a wrapper for item arrays.
150150

151151

152+
## Links
153+
154+
All objects that can have links use an instance of `Links` to store their links.
155+
These are in turn an instance of `Link`.
156+
157+
### Example
158+
159+
Given the following JSON:
160+
``` json
161+
{
162+
"data": [],
163+
"links": {
164+
"self": "http://example.com/test"
165+
}
166+
}
167+
```
168+
169+
You can get the links this way:
170+
``` php
171+
/** @var $document \Swis\JsonApi\Client\Document */
172+
$links = $document->getLinks();
173+
echo $links->self->getHref(); // http://example.com/test
174+
```
175+
176+
177+
## Meta
178+
179+
All objects that can have meta information use an instance of `Meta` to store their metadata.
180+
This is a simple array-like object with key-value pairs.
181+
182+
### Example
183+
184+
Given the following JSON:
185+
``` json
186+
{
187+
"data": [],
188+
"meta": {
189+
"foo": "bar"
190+
}
191+
}
192+
```
193+
194+
You can get the meta this way:
195+
``` php
196+
/** @var $document \Swis\JsonApi\Client\Document */
197+
$meta = $document->getMeta();
198+
echo $meta->foo; // bar
199+
```
200+
201+
152202
## TypeMapper
153203

154204
All custom models must be registered with the `TypeMapper`.

0 commit comments

Comments
 (0)