Skip to content

Instantly share code, notes, and snippets.

@Cyberiaaxis
Created November 12, 2017 14:13
Show Gist options
  • Save Cyberiaaxis/d78b1184caf0d1a8045d5b9fd74ad293 to your computer and use it in GitHub Desktop.
Save Cyberiaaxis/d78b1184caf0d1a8045d5b9fd74ad293 to your computer and use it in GitHub Desktop.
public function store(Request $request)
{
$ques = new Question();
$ques->question_text = $request['question_text'];
$ques->code_snippet = $request['code_snippet'];
$ques->answer_explanation = $request['answer_explanation'];
$ques->more_info_link = $request['more_info_link'];
$ques->category_id = $request['category_id'];
$ques->topic_id = $request['topic_id'];
$ques->save();
$i=0;
foreach($request as $key){
print_r($request['correct']);
$questionOption = new QuestionsOption();
$questionOption->question_id = $ques->id;
$questionOption->option = $request['option'. $i];
if($request['option'. $i] == $request['correct']){
$questionOption->option = 1;
}
$questionOption->save();
$i++;
}
@kilitary
Copy link

what is wrong here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment