Skip to content

Instantly share code, notes, and snippets.

@Cyberiaaxis
Created November 15, 2017 01:46
Show Gist options
  • Save Cyberiaaxis/810287aea567d3a4cae9f128f4a69de8 to your computer and use it in GitHub Desktop.
Save Cyberiaaxis/810287aea567d3a4cae9f128f4a69de8 to your computer and use it in GitHub Desktop.
$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();
$data = [];
$now = Carbon::now();
foreach($request->option as $key => $value) {
$data[] = [
'question_id' => $ques->id,
'answers' => $value,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
];
}
QuestionsOption::insert($data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment