I am trying to import excel file in Laravel using Maatwebsite version 3.1. If my excel has all columns filled I have no problem but if some cells are missing it stops working and gives an error
"Error Exception (E_NOTICE) Undefined offset: 1"
public function model(array $row)
{
if(sizeof($row[0]) >0 and sizeof($row[1]) >0 and sizeof($row[2]) >0 and sizeof($row[3]) >0 and sizeof($row[4]) >0 and sizeof($row[5] > 0 ){
return new TempLeads([
'description' => $row[0],
'name' => $row[1],
'email' => $row[2],
'mobile' => $row[3],
'city' => $row[4],
'company_name' => $row[5],
'project' => 'Bahria',
'date' => date('Y-m-d'),
]);
}
}
Above code works if all columns and cells fill in excel file. Data is inserted in table
I want to import data with some missing cells but not the entire Row and also want to skip empty row.