File tree Expand file tree Collapse file tree 1 file changed +10
-13
lines changed Expand file tree Collapse file tree 1 file changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -86,23 +86,20 @@ php artisan vendor:publish --provider="Swis\JsonApi\Client\Providers\ServiceProv
86
86
87
87
## Getting started
88
88
89
- You can simply require the [ DocumentClient] ( #documentclient ) as a dependency and use it in your class.
90
- Alternatively, you can create a repository based on ` \Swis\JsonApi\Client\Repository ` and use that as a dependency:
89
+ You can simply create an instance of [ DocumentClient] ( #documentclient ) and use it in your class.
90
+ Alternatively, you can create a [ repository] ( #repository ) .
91
91
92
92
``` php
93
- use Swis\JsonApi\Client\Repository
93
+ use Swis\JsonApi\Client\DocumentClient;
94
94
95
- class BlogRepository extends Repository
96
- {
97
- protected $endpoint = 'blogs';
98
- }
95
+ $client = DocumentClient::create();
96
+ $document = $client->get('https://cms.contentacms.io/api/recipes');
99
97
100
- $repository = app(BlogRepository::class);
101
- $document = $repository->all();
102
- if ($document->hasErrors()) {
103
- // do something with errors
104
- } else {
105
- $blogs = $document->getData();
98
+ /** @var \Swis\JsonApi\Client\Collection& \Swis\JsonApi\Client\Item[] $collection */
99
+ $collection = $document->getData();
100
+
101
+ foreach ($collection as $item) {
102
+ // Do stuff with the items
106
103
}
107
104
```
108
105
You can’t perform that action at this time.
0 commit comments