1 | <?php |
||
5 | class ResourceSerializer extends JsonApiSerializer |
||
6 | { |
||
7 | /** |
||
8 | * The model instance to transform. |
||
9 | * |
||
10 | * @var \Illuminate\Database\Eloquent\Model |
||
11 | */ |
||
12 | protected $record; |
||
13 | |||
14 | /** |
||
15 | * The record relationships to return. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $relationships; |
||
20 | |||
21 | /** |
||
22 | * The subset of record attributes to return. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $fields; |
||
27 | |||
28 | /** |
||
29 | * The relationships to load and include. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $include; |
||
34 | |||
35 | /** |
||
36 | * Create a new JSON API resource serializer. |
||
37 | * |
||
38 | * @param Model $record The model instance to serialise |
||
39 | * @param array|null $fields Subset of fields to return |
||
40 | * @param array|null $include Relations to include |
||
41 | */ |
||
42 | public function __construct($record, array $fields = [], array $include = []) |
||
51 | |||
52 | /** |
||
53 | * Limit which relations can be included. |
||
54 | * |
||
55 | * @param array $include |
||
56 | */ |
||
57 | public function scopeIncludes($include) |
||
61 | |||
62 | /** |
||
63 | * Return a JSON API resource identifier object for the primary record. |
||
64 | * |
||
65 | * @return array |
||
66 | */ |
||
67 | public function toResourceIdentifier() |
||
74 | |||
75 | /** |
||
76 | * Return a base JSON API resource object for the primary record containing |
||
77 | * only immediate attributes. |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | public function toBaseResourceObject() |
||
87 | |||
88 | /** |
||
89 | * Return a full JSON API resource object for the primary record. |
||
90 | * |
||
91 | * @return array |
||
92 | */ |
||
93 | public function toResourceObject() |
||
101 | |||
102 | /** |
||
103 | * Return a collection of JSON API resource objects for each included |
||
104 | * relationship. |
||
105 | * |
||
106 | * @return \Illuminate\Support\Collection |
||
107 | */ |
||
108 | public function getIncludedRecords() |
||
114 | |||
115 | /** |
||
116 | * Return primary data for the JSON API document. |
||
117 | * |
||
118 | * @return array |
||
119 | */ |
||
120 | protected function getPrimaryData() |
||
124 | |||
125 | /** |
||
126 | * Return any secondary included resource data. |
||
127 | * |
||
128 | * @return array |
||
129 | */ |
||
130 | protected function getIncludedData() |
||
134 | |||
135 | /** |
||
136 | * Return the primary record type name. |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | protected function getRecordType() |
||
146 | |||
147 | /** |
||
148 | * Return the attribute object data for the primary record. |
||
149 | * |
||
150 | * @return array |
||
151 | */ |
||
152 | protected function transformRecordAttributes() |
||
163 | |||
164 | /** |
||
165 | * Return a collection of JSON API resource identifier objects by each |
||
166 | * relation on the primary record. |
||
167 | * |
||
168 | * @return \Illuminate\Support\Collection |
||
169 | */ |
||
170 | protected function transformRecordRelations() |
||
178 | } |
||
179 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..