1 | <?php |
||
7 | class CollectionSerializer extends JsonApiSerializer |
||
8 | { |
||
9 | /** |
||
10 | * The collection of records to transform. |
||
11 | * |
||
12 | * @var \Illuminate\Support\Collection |
||
13 | */ |
||
14 | protected $records; |
||
15 | |||
16 | /** |
||
17 | * The subset of attributes to return on each record type. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $fields; |
||
22 | |||
23 | /** |
||
24 | * The relationships to load and include. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $include; |
||
29 | |||
30 | /** |
||
31 | * Create a new JSON API collection serializer. |
||
32 | * |
||
33 | * @param \Illuminate\Support\Collection|LengthAwarePaginator $records The collection of records to serialize |
||
34 | * @param array|null $fields Subset of fields to return by record type |
||
35 | * @param array|null $include Relations to include |
||
36 | */ |
||
37 | public function __construct($records, array $fields = [], array $include = []) |
||
52 | |||
53 | /** |
||
54 | * Return a collection of JSON API resource objects for the record set. |
||
55 | * |
||
56 | * @return \Illuminate\Support\Collection |
||
57 | */ |
||
58 | public function toResourceCollection() |
||
64 | |||
65 | /** |
||
66 | * Return primary data for the JSON API document. |
||
67 | * |
||
68 | * @return mixed |
||
69 | */ |
||
70 | protected function getPrimaryData() |
||
74 | |||
75 | /** |
||
76 | * Return any secondary included resource objects. |
||
77 | * |
||
78 | * @throws \Huntie\JsonApi\Exceptions\InvalidRelationPathException |
||
79 | * |
||
80 | * @return \Illuminate\Support\Collection |
||
81 | */ |
||
82 | public function getIncluded() |
||
95 | |||
96 | /** |
||
97 | * Add pagination links and meta information to the main document. |
||
98 | * |
||
99 | * @param LengthAwarePaginator $paginator |
||
100 | */ |
||
101 | protected function addPaginationLinks($paginator) |
||
112 | } |
||
113 |