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