Conditions | 5 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
32 | protected function includeRelations() |
||
33 | { |
||
34 | $relations = []; |
||
35 | foreach ($this->relations as $relation) { |
||
36 | if (is_string($relation) && method_exists(static::class, 'transform' . ucfirst(strtolower($relation)))) { |
||
37 | $method = 'transform' . ucfirst(strtolower($relation)); |
||
38 | $data = $this->$method($this->resource); |
||
39 | if ($data instanceof JsonResource) { |
||
40 | $data->jsonSerialize(); |
||
41 | } |
||
42 | $relations[strtolower($relation)] = $data; |
||
43 | } else { |
||
44 | throw new \Exception("invalid relation or not relation_transform_method given in " . get_short_class_name(static::class)); |
||
45 | } |
||
46 | |||
47 | } |
||
48 | return $relations; |
||
49 | } |
||
66 |