Issues (52)

src/Seeds/ProvincesTableSeeder.php (1 issue)

Labels
Severity
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
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

27
        }, /** @scrutinizer ignore-type */ $data);
Loading history...
28
29
        Province::insert($provinces);
30
    }
31
}
32