| Conditions | 6 |
| Paths | 5 |
| Total Lines | 20 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public function handle() |
||
| 18 | { |
||
| 19 | $response = IproSoftwareFacade::getLocationsList()->onlySuccessful(); |
||
| 20 | |||
| 21 | $groups = $response->json(); |
||
| 22 | if (is_array($groups) && !empty($groups)) { |
||
| 23 | foreach ($groups as $items) { |
||
| 24 | foreach ($items['Children'] ?? [] as $item) { |
||
| 25 | if (!isset($item['Id'])) { |
||
| 26 | continue; |
||
| 27 | } |
||
| 28 | Location::firstOrNew(['id' => $item['Id']], ) |
||
| 29 | ->fill([ |
||
| 30 | 'name' => $item['Name'], |
||
| 31 | 'type_id' => $items['Id'], |
||
| 32 | 'type' => $items['Name'], |
||
| 33 | 'children' => $item['Children'] ?? [], |
||
| 34 | ]) |
||
| 35 | ->fillPulled() |
||
| 36 | ->save(); |
||
| 37 | } |
||
| 42 |