How to collect the answers to custom questions? (so that is possible to store the answers in the answers table)

The $request->all(), using “participant[$k][questions][][question_id][$customQuestionId][answer]” and " participant[{{$k}}][name]" shows like:

array:4 [▼
  "participant" => array:3 [▼
    "general" => array:2 [▼
      "name" => "Jake"
      "surname" => "K"
    ]
    1 => array:1 [▼
      "questions" => array:2 [▼
        0 => array:1 [▼
          "question_id" => array:1 [▼
            1 => array:1 [▼
              "answer" => "answer1"
            ]
          ]
        ]
        1 => array:1 [▼
          "question_id" => array:1 [▼
            2 => array:1 [▼
              "answer" => "answer2"
            ]
          ]
        ]
      ]
    ]
    "plus" => array:2 [▼
      "name" => "John"
      "surname" => "K"
    ]
  ]
]

What I gather is, you know how to access it then? I would alias it for a more abbreviated usage.

Sponsor our Newsletter | Privacy Policy | Terms of Service