| Conditions | 1 |
| Paths | 1 |
| Total Lines | 18 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public function run() |
||
| 11 | { |
||
| 12 | $Csv = new CsvtoArray(); |
||
| 13 | $file = __DIR__.'/../../resources/csv/cities.csv'; |
||
| 14 | $header = ['id', 'province_id', 'name', 'lat', 'long']; |
||
| 15 | $data = $Csv->csv_to_array($file, $header); |
||
| 16 | $cities = array_map(function ($arr) { |
||
| 17 | return [ |
||
| 18 | 'state_id' => $arr['province_id'], |
||
| 19 | 'name' => $arr['name'], |
||
| 20 | 'latitude' => $arr['lat'], |
||
| 21 | 'longitude' => $arr['long'], |
||
| 22 | 'created_at' => now()->toDateTimeString(), |
||
| 23 | 'updated_at' => now()->toDateTimeString(), |
||
| 24 | ]; |
||
| 25 | }, $data); |
||
|
|
|||
| 26 | |||
| 27 | City::insert($cities); |
||
| 28 | } |
||
| 30 |