1 | <?php |
||
12 | trait JsonApiTransforms |
||
13 | { |
||
14 | /** |
||
15 | * Transform a model instance into a JSON API object. |
||
16 | * |
||
17 | * @param Model $record |
||
18 | * @param array|null $fields Field subset to return |
||
19 | * @param array|null $include Relations to include |
||
20 | * |
||
21 | * @return array |
||
22 | */ |
||
23 | protected function transformRecord($record, array $fields = [], array $include = []) |
||
59 | |||
60 | /** |
||
61 | * Transform a model instance into a JSON API object without additonal data. |
||
62 | * |
||
63 | * @param Model $record |
||
64 | * |
||
65 | * @return array |
||
66 | */ |
||
67 | protected function transformRecordSimple($record) |
||
80 | |||
81 | /** |
||
82 | * Transform a model instance into a JSON API resource identifier. |
||
83 | * |
||
84 | * @param Model $record |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | protected function transformRecordIdentifier($record) |
||
97 | |||
98 | /** |
||
99 | * Transform a set of models into a JSON API collection. |
||
100 | * |
||
101 | * @param Collection|LengthAwarePaginator $records |
||
102 | * @param array $fields |
||
103 | * @param array|null $include |
||
104 | * |
||
105 | * @return array |
||
106 | */ |
||
107 | protected function transformCollection($records, array $fields = [], array $include = []) |
||
132 | |||
133 | /** |
||
134 | * Transform a set of models into a JSON API collection without additional data. |
||
135 | * |
||
136 | * @param Collection $records |
||
137 | * |
||
138 | * @return array |
||
139 | */ |
||
140 | protected function transformCollectionSimple($records) |
||
148 | |||
149 | /** |
||
150 | * Transform a set of models into a collection of JSON API resource |
||
151 | * identifier objects. |
||
152 | * |
||
153 | * @param Collection $records |
||
154 | * |
||
155 | * @return array |
||
156 | */ |
||
157 | protected function transformCollectionIdentifiers($records) |
||
165 | |||
166 | /** |
||
167 | * Transform a model relationship into a single, or collection of, JSON API |
||
168 | * resource identifier objects. |
||
169 | * |
||
170 | * @param Model $record |
||
171 | * @param string $relation |
||
172 | * |
||
173 | * @return array |
||
174 | */ |
||
175 | protected function transformRelationship($record, $relation) |
||
187 | } |
||
188 |