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