Issues (52)

src/Seeds/DistrictsTableSeeder.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Turahe\Master\Seeds;
4
5
use Illuminate\Database\Seeder;
6
use Turahe\Master\Models\District;
7
8
class DistrictsTableSeeder extends Seeder
9
{
10
    public function run()
11
    {
12
        $now = now()->toDateTimeString();
13
        $csv = new CsvtoArray();
14
        $file = __DIR__.'/../../resources/csv/districts.csv';
15
        $header = ['id', 'city_id', 'name', 'lat', 'long'];
16
        $data = $csv->csv_to_array($file, $header);
17
        $districts = array_map(function ($arr) use ($now) {
18
            return [
19
                'name' => $arr['name'],
20
                'city_id' => $arr['city_id'],
21
                'latitude' => $arr['lat'],
22
                'longitude' => $arr['long'],
23
                'created_at' => $now,
24
                'updated_at' => $now,
25
            ];
26
        }, $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

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