Trying to import excel data to my mysql db and getting ErrorException Undefined offset: 0.
Tried using var_dump($row) to check the array of the row of the data. It looks off and not sure how to make the data shows nicely so that able to pass to db.
array(5) { ["a"]=> string(1) "B" ["white"]=> string(5) "Green" ["example1_at_gmailcom"]=> string(18) "[email protected]" [60123456789]=> int(60162313142) [5]=> int(5) }
This is my excel data:
Model
public function model(array $row)
{
var_dump($row);
return new ContactList([
'first_name' => $row[0],
'last_name' => $row[1],
'email' => $row[2],
'phone' => $row[3],
'group_id' => $row[4],
]);
}
I already tried using replacing the $row[] with string and it works perfectly storing the data into my db.
Controller
if($request->hasFile('selected_file')){
$file = $request->file('selected_file');
Excel::import(new ContactListsImport, $file);
return redirect()->back()->with('success', 'Data saved successfully!');
}

0in it?0as you can see as you dumped the array and there is no key0... you can't access keys of an array that don't exist ... you have an issue here as the first row of this file is being used as the headers (column names), you should look into the documentation to adjust this or not use this behavior