Skip to content

Commit 5d03da0

Browse files
committed
Update getting started section
1 parent bf21de7 commit 5d03da0

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

README.MD

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,20 @@ php artisan vendor:publish --provider="Swis\JsonApi\Client\Providers\ServiceProv
8686

8787
## Getting started
8888

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).
9191

9292
``` php
93-
use Swis\JsonApi\Client\Repository
93+
use Swis\JsonApi\Client\DocumentClient;
9494

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');
9997

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
106103
}
107104
```
108105

0 commit comments

Comments
 (0)