i have some problem that Laravel WithHeadingRow does not working.
for example, i have this kind of excel file.
| productId | productName |
|---|---|
| 2132 | example_name |
but i can't load rowheader using WithHeadingRow.
code:
class RandomRotationProductImport implements ToModel, WithHeadingRow
{
public function model(array $row): ?RandomRotationProduct
{
return new RandomRotationProduct([
'product_id' => $row['product_id'],
'product_name' => $row['product_name']
]);
}
public function headingRow(): int
{
return 0;
}
}
but this cause the error: "message": "Undefined index: product_id"
is there anything to solve this problem?