[Mapped Cells] How to handle nested mapping / multiple mapped entities #3999
-
Example table:
Objective: Save each player with score and team Sadly this type of nested import isn't supported: public function mapping(): array
{
return [
'team_1' => [
[
'name' => 'A2',
'score' => 'B2',
],
[
'name' => 'A3',
'score' => 'B3',
],
],
'team_2' => [
[
'name' => 'C2',
'score' => 'D2',
],
[
'name' => 'C3',
'score' => 'D3',
],
],
...
];
} Anybody got an idea to solve this? public function mapping(): array
{
return [
'team_1_1_name' => 'A2',
'team_1_1_score' => 'B2',
'team_1_2_name' => 'A3',
'team_1_2_score' => 'B3',
'team_2_1_name' => 'C2',
'team_2_1_score' => 'D2',
'team_2_2_name' => 'C3',
'team_2_2_score' => 'D3',
...
];
} Would be possible but is not nice to handle afterwards. Another option would be running the Importer once for every team. |
Beta Was this translation helpful? Give feedback.
Answered by
typingbeaver
Sep 21, 2023
Replies: 1 comment
-
Created a PR (#4000) for nested mapping arrays. Another soulution would be using public function mapping(): array
{
return collect([...])->dot()->toArray()
} And denesting it afterwards with collect($row)->undot() |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
typingbeaver
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created a PR (#4000) for nested mapping arrays.
Another soulution would be using
And denesting it afterwards with