Conditions | 2 |
Paths | 1 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
14 | public function run() |
||
15 | { |
||
16 | $response = []; |
||
17 | |||
18 | Capsule::table( config('geography.nameTable.country') )->get()->each(function ($item) use ( &$response ) |
||
19 | { |
||
20 | $body = file_get_contents('https://api.vk.com/method/database.getRegions?v=5.5&count=1000&country_id=' . $item->id . |
||
21 | '&access_token=' . config('geography.access_token')); |
||
22 | $responseArray = json_decode($body, true); |
||
23 | |||
24 | foreach ($responseArray['response']['items'] as &$iterator) |
||
25 | { |
||
26 | $response[] = [ |
||
27 | 'id' => $iterator['id'], |
||
28 | 'title' => $iterator['title'], |
||
29 | 'country_id' => $item->id |
||
30 | ]; |
||
31 | } |
||
32 | }); |
||
33 | |||
34 | Capsule::table(config('geography.nameTable.regions'))->insert($response); |
||
35 | } |
||
36 | } |
||
37 |