1 | <?php |
||
2 | |||
3 | namespace Turahe\Master\Seeds; |
||
4 | |||
5 | use Carbon\Carbon; |
||
6 | use Illuminate\Database\Seeder; |
||
7 | use Turahe\Master\Models\Province; |
||
8 | |||
9 | class ProvincesTableSeeder extends Seeder |
||
10 | { |
||
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); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
28 | |||
29 | Province::insert($provinces); |
||
30 | } |
||
31 | } |
||
32 |