Conditions | 6 |
Paths | 5 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | protected function loadRecursively(RegionModel $region, string $code, int $deep = 0):Collection |
||
27 | { |
||
28 | $regions = new Collection(); |
||
29 | if ($region->code === $code) { |
||
30 | $regions = $region->children; |
||
31 | if ($deep > 0) { |
||
32 | foreach ($region->children as $child) { |
||
33 | $regions = $regions->merge($this->loadRecursively($child, $code, $deep - 1)); |
||
34 | } |
||
35 | } |
||
36 | } else { |
||
37 | foreach ($region->children as $child) { |
||
38 | $regions = $this->loadRecursively($child, $code, $deep); |
||
39 | if ($regions->isNotEmpty()) { |
||
40 | break; |
||
41 | } |
||
42 | } |
||
43 | } |
||
44 | return $regions; |
||
45 | } |
||
55 | } |