I have this:
$csv = Reader::createFromPath(__DIR__.'/data/manufacturers.csv', 'r');
$csv->setHeaderOffset(0);
$headers = $csv->getHeader();
$records = $csv->getRecords();
foreach ($records as $r) {
$cols = array_combine($headers, $r);
$i = [];
foreach($headers as $h)
{
if($h == 'dealer') $cols[$h] = boolval($cols[$h]);
//elseif(empty($cols[$h])) $cols[$h] == '...';
print "$h\n"; var_dump($cols[$h]);
$i[$h] = $cols[$h];
}
\Modules\Cars\Entities\Manufacturer::create($i);
}
and as you can see I'm doing some troubleshooting, the commented out line does nothing, and I don't know why. Resulting output:
Seeding: Modules\Cars\Database\Seeders\ManufacturersTableSeeder
title
string(15) "Rolls"
dealer
bool(false)
url
string(0) ""
summary
string(0) ""
logo
string(0) ""
[ErrorException]
A non well formed numeric value encountered
The url column in the first row is blank, as was the dealer one, until I made it 0 to test this. How do I remedy it? Some fields are going to be blank. I tried setting them to null, too.