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 = []) |
||
60 | |||
61 | /** |
||
62 | * Transform a model instance into a JSON API object without additonal data. |
||
63 | * |
||
64 | * @param Model $record |
||
65 | * |
||
66 | * @return array |
||
67 | */ |
||
68 | protected function transformRecordSimple($record) |
||
81 | |||
82 | /** |
||
83 | * Transform a model instance into a JSON API resource identifier. |
||
84 | * |
||
85 | * @param Model $record |
||
86 | * |
||
87 | * @return array |
||
88 | */ |
||
89 | protected function transformRecordIdentifier($record) |
||
98 | |||
99 | /** |
||
100 | * Transform a set of models into a JSON API collection. |
||
101 | * |
||
102 | * @param Collection|LengthAwarePaginator $records |
||
103 | * @param array $fields |
||
104 | * @param array|null $include |
||
105 | * |
||
106 | * @return array |
||
107 | */ |
||
108 | protected function transformCollection($records, array $fields = [], array $include = []) |
||
133 | |||
134 | /** |
||
135 | * Transform a set of models into a JSON API collection without additional data. |
||
136 | * |
||
137 | * @param Collection $records |
||
138 | * |
||
139 | * @return array |
||
140 | */ |
||
141 | protected function transformCollectionSimple($records) |
||
149 | |||
150 | /** |
||
151 | * Transform a set of models into a collection of JSON API resource |
||
152 | * identifier objects. |
||
153 | * |
||
154 | * @param Collection $records |
||
155 | * |
||
156 | * @return array |
||
157 | */ |
||
158 | protected function transformCollectionIdentifiers($records) |
||
166 | |||
167 | /** |
||
168 | * Transform a model relationship into a single, or collection of, JSON API |
||
169 | * resource identifier objects. |
||
170 | * |
||
171 | * @param Model $record |
||
172 | * @param string $relation |
||
173 | * |
||
174 | * @return array |
||
175 | */ |
||
176 | protected function transformRelationship($record, $relation) |
||
188 | } |
||
189 |