Replies: 1 comment 1 reply
-
No plans to change this right now. Make sure the map function returns the columns in the right order. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
currently WithMapping only supports direct array mapping. So basically:
$heading = ['column1', 'column2', 'column3'];
in mapping we are not able to return ['column3' => 'something', 'column1' => 'this']
It always takes the array with the same order, the mapping keys are ignored.
Perhaps implement following function to have "mapToColumns":
@params $record = ['Heading3' => 'valueOf3', 'Heading1' => 'valueOf1', 'Heading2' => 'valueOf2'] //Notice the order is irrelevant
`public function mapToColumns($record): array
{
$all_fields = $this->headings()[0]; // Lets say this is ['Heading1', 'Heading2', 'Heading3']
$mapped_key_value_pair = array_fill_keys($all_fields, '');
Beta Was this translation helpful? Give feedback.
All reactions