Advertisement
Guest User

Untitled

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