Advertisement
Guest User

Untitled

a guest
May 25th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. $question = new Question();
  2. $answer = new Answer();
  3. foreach ($request->get('questions') as $idnex => $question) {
  4.     $question->book_id = $request->get('bookId');
  5.     $question->question = $question;
  6.     $question->save();
  7.     foreach ($request->get('answers') as $idnex => $answer) {
  8.         $answer->answer = $answer;
  9.         $answer->question_id = $question->id;
  10.         if ($request->has("isCorrect[{$index}]")) {
  11.             $answer->is_correct = 1;
  12.         } else {
  13.             $answer->is_correct = 0;
  14.         }
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement