Issues (52)

src/Seeds/CitiesTableSeeder.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Turahe\Master\Seeds;
4
5
use Illuminate\Database\Seeder;
6
use Turahe\Master\Models\City;
7
8
class CitiesTableSeeder extends Seeder
9
{
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);
0 ignored issues
show
It seems like $data can also be of type false; however, parameter $arr1 of array_map() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
        }, /** @scrutinizer ignore-type */ $data);
Loading history...
26
27
        City::insert($cities);
28
    }
29
}
30