Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TheBlueDragon's avatar

How to read from different text input and save in different row ?

hello, i just want to know what is the way to make an more than one input and save with eloquent

for example i have a quiz project

each quiz will have 3 option one is correct and image for the question

questions:
- id
- question 
- image

answers: - id - answer - question_id - correct

my view is

Add new Question

                        <!-- Textarea -->
                        <div class="form-group">
                            <label class="col-md-4 control-label" for="question">Question</label>
                            <div class="col-md-4">
                                <textarea class="form-control" id="question" name="question"></textarea>
                            </div>
                        </div>

                        <!-- Prepended checkbox -->
                        <div class="form-group">
                            <label class="col-md-4 control-label" for="Answer1">Answer</label>
                            <div class="col-md-4">
                                <div class="input-group">
                      <span class="input-group-addon">
                          <input type="checkbox">
                      </span>
                                    <input id="Answer1" name="Answer1" class="form-control" type="text" placeholder="">
                                </div>

                            </div>
                        </div>

                        <!-- Prepended checkbox -->
                        <div class="form-group">
                            <label class="col-md-4 control-label" for="Answer2">Answe</label>
                            <div class="col-md-4">
                                <div class="input-group">
                      <span class="input-group-addon">
                          <input type="checkbox">
                      </span>
                                    <input id="Answer2" name="Answer2" class="form-control" type="text" placeholder="">
                                </div>

                            </div>
                        </div>

                        <!-- Prepended checkbox -->
                        <div class="form-group">
                            <label class="col-md-4 control-label" for="Answer3">Answer</label>
                            <div class="col-md-4">
                                <div class="input-group">
                      <span class="input-group-addon">
                          <input type="checkbox">
                      </span>
                                    <input id="Answer3" name="Answer3" class="form-control" type="text" placeholder="">
                                </div>

                            </div>
                        </div>

its ok i can grab the question and save it but for the answer how i can grab the 3 question and save them

for the logic i write for now

grab question > store > take the saved question id

grab answer > store

in same method but i didnt find a way for taking the 3 input as one with there checked answer

i try to do like this

$request->input('Answer1'); and save etc... and i feel its not that much

so i hope i can get some expert with this kind of issues !!

and i hope i explane every thing is needed !!

0 likes
0 replies

Please or to participate in this conversation.