can't you pair program with @rushita
See my answer there
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i have two migrations quiz and option when i update a question and option but only update question and first option update in all three option are same value so how to update all option in particalur question
here is my controller file
public function question(Request $request,$id)
{
\DB::table('quiz')
->where('id','=',$id)
->update([
'question' => $request->get('question'),
]);
$qid=quiz::where('id','=',$id)->get();
$option=$request->get('option');
foreach($option as $option)
{
\DB::table('opts')
->where('qid','=',$id)
->update([
'option'=> $options
]);
}
return back();
}
thanks
consider this
foreach($option as $option)
{
\DB::table('opts')
->where('qid','=',$id)
->update([
'option'=> $options
]);
}
You say you have four options. All options with have the same qid
Each time around the loop, you are telling your database to set all options with that qid with $data. As there are four records that match that where statement then they all get updated.
Next time around the loop again, you update the same four records, etc
Your choice is either
a) delete all the options first and use insert in your loop
b) give each option an id and keep trackof this in your front end. You can then update specific option id
Please or to participate in this conversation.