22
33## Introduction
44
5- This package supports the [ inclusion of related resources] ( http://jsonapi.org/format/1.0/#fetching-includes ) .
5+ This package supports the [ inclusion of related resources] ( http://jsonapi.org/format/1.0/#fetching-includes ) .
66This allows a client to specify resources related to the primary data that should be included in the response.
77The purpose is to allow the client to reduce the number of HTTP requests it needs to make to obtain all the data
88it requires.
@@ -20,13 +20,13 @@ For this feature to work, you will need to:
2020default validators do not allow include paths.
21212 . Add relationships to the resource [ Schema] ( ../basics/schemas.md ) and ensure they return data.
22223 . For Eloquent models, define the translation of any JSON API include paths to eager load paths
23- on the resource [ Adapter] ( ../basics/adapters.md ) .
23+ on the resource [ Adapter] ( ../basics/adapters.md ) .
2424
2525These are all described in this chapter.
2626
2727## The Include Query Parameter
2828
29- Related resources are specified by the client using the ` include ` query parameter. This parameter
29+ Related resources are specified by the client using the ` include ` query parameter. This parameter
3030contains a comma separated list of relationship paths that should be included. The response will be a
3131[ compound document] ( http://jsonapi.org/format/#document-compound-documents ) where the primary data of the
3232request is in the JSON's ` data ` member, and the related resources are in the ` included ` member.
@@ -37,7 +37,7 @@ resources in the same request:
3737``` http
3838GET /api/posts?include=author,tags HTTP/1.1
3939Accept: application/vnd.api+json
40- ```
40+ ```
4141
4242If these include paths are valid, then the client will receive the following response:
4343
@@ -79,7 +79,7 @@ Content-Type: application/vnd.api+json
7979 "links": {
8080 "self": "/api/posts/123/relationships/tags",
8181 "related": "/api/posts/123/tags"
82- }
82+ }
8383 }
8484 },
8585 "links": {
@@ -130,7 +130,7 @@ relationship, the client could request the following:
130130``` http
131131GET /api/posts?include=author.address,tags HTTP/1.1
132132Accept: application/vnd.api+json
133- ```
133+ ```
134134
135135For this request, both the author ` users ` resource and the user's ` addresses ` resource would be present in
136136the ` included ` member of the JSON document.
@@ -201,7 +201,7 @@ class Validators extends AbstractValidators
201201 'author.address',
202202 'tags'
203203 ];
204-
204+
205205 // ...
206206}
207207```
@@ -235,7 +235,7 @@ the posts schema would have to return both the related author and the related ta
235235``` php
236236namespace App\JsonApi\Posts;
237237
238- use Neomerx\JsonApi \Schema\SchemaProvider;
238+ use CloudCreativity\LaravelJsonApi \Schema\SchemaProvider;
239239
240240class Schema extends SchemaProvider
241241{
@@ -278,7 +278,7 @@ method on the `users` schema.
278278
279279## Eager Loading
280280
281- The Eloquent adapter automatically converts JSON API include paths to Eloquent model
281+ The Eloquent adapter automatically converts JSON API include paths to Eloquent model
282282[ eager loading] ( https://laravel.com/docs/eloquent-relationships#eager-loading ) paths.
283283The JSON API path is converted to a camel-case path. For example, the JSON API path
284284` author.current-address ` is converted to the ` author.currentAddress ` Eloquent path.
@@ -299,7 +299,7 @@ class Adapter extends AbstractAdapter
299299 'author' => 'createdBy',
300300 'author.current-address' => 'createdBy.currentAddress',
301301 ];
302-
302+
303303 // ...
304304}
305305```
@@ -324,7 +324,7 @@ requested as primary data:
324324``` php
325325namespace App\JsonApi\Posts;
326326
327- use Neomerx\JsonApi \Schema\SchemaProvider;
327+ use CloudCreativity\LaravelJsonApi \Schema\SchemaProvider;
328328
329329class Schema extends SchemaProvider
330330{
@@ -344,7 +344,7 @@ This would mean that the following request receive a response with `users` and `
344344``` http
345345GET /api/posts HTTP/1.1
346346Accept: application/vnd.api+json
347- ```
347+ ```
348348
349349### Default Path Eager Loading
350350
@@ -359,7 +359,7 @@ use CloudCreativity\LaravelJsonApi\Eloquent\AbstractAdapter;
359359class Adapter extends AbstractAdapter
360360{
361361 protected $defaultWith = ['author', 'tags'];
362-
362+
363363 // ...
364364}
365365```
0 commit comments