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