Trying to figure out why I am getting the following error:
Undefined index Plugin ID
I am using Maatwebsite\Excel for my import and tried using the guide here:
https://appdividend.com/2017/06/12/import-export-data-csv-excel-laravel-5-4/
I think I have everything in the right place, but I am getting the above error from this code:
public function import(Request $request)
{
if($request->file('imported-file'))
{
$path = $request->file('imported-file')->getRealPath();
$data = Excel::load($path, function($reader)
{
})->get();
if(!empty($data) && $data->count())
{
foreach ($data->toArray() as $row)
{
if(!empty($row))
{
$dataArray[] =
[
'plugin_id' => $row['Plugin ID'],
'cve' => $row['CVE'],
'cvss' => $row['CVSS'],
'risk' => $row['Risk'],
'host' => $row['Host'],
'protocol' => $row['Protocol'],
'port' => $row['Port'],
'name' => $row['Name'],
'synopsis' => $row['Synopsis'],
'description' => $row['Description'],
'solution' => $row['Solution'],
'see_also' => $row['See Also'],
'plugino_utput' => $row['Plugin Output']
];
}
}
if(!empty($dataArray))
{
Shipping::insert($dataArray);
return back();
}
}
}
}
This is in my controller file and is trying to account for the headers being different in the CSV compared to in my database.
Any idea why it would be complaining about index on a column from the csv side of things?