/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\AnswerRequest $request)
 {
     $Answer = new \App\Answer();
     $Answer->answer = $request->get('answer');
     $Answer->user_id = \Auth::user()->id;
     $Answer->question_id = $request->get('question_id');
     $Answer->save();
     \Session::flash('flash_message', 'Your Answer has been Posted !!!');
     return redirect()->back();
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function reply(Request $request, $id)
 {
     $this->validate($request, ['answer' => 'required']);
     $answer = new \App\Answer();
     $answer->answer = $request->get('answer');
     $answer->question_id = $id;
     $answer->user_id = Auth::user()->id;
     if ($answer->save()) {
         Session::flash('message', "Answer submitted , Thank you .");
     }
     return redirect('question/' . $id);
 }
Example #3
0
 public function run()
 {
     DB::table('answers')->truncate();
     App\Answer::create(['description' => 'one', 'is_correct' => false, 'question_id' => 1]);
     App\Answer::create(['description' => 'Bill Gates', 'is_correct' => false, 'question_id' => 2]);
     App\Answer::create(['description' => 'John Lennon', 'is_correct' => false, 'question_id' => 2]);
     App\Answer::create(['description' => 'four', 'is_correct' => true, 'question_id' => 1]);
     App\Answer::create(['description' => 'five', 'is_correct' => false, 'question_id' => 1]);
     App\Answer::create(['description' => 'Mark Zukerberg', 'is_correct' => true, 'question_id' => 2]);
     App\Answer::create(['description' => 'nine', 'is_correct' => true, 'question_id' => 3]);
     App\Answer::create(['description' => 'ninty nine', 'is_correct' => false, 'question_id' => 3]);
     App\Answer::create(['description' => '23', 'is_correct' => false, 'question_id' => 4]);
     App\Answer::create(['description' => '24', 'is_correct' => true, 'question_id' => 4]);
     App\Answer::create(['description' => '25', 'is_correct' => false, 'question_id' => 4]);
     App\Answer::create(['description' => 'Paul McCartney', 'is_correct' => false, 'question_id' => 5]);
     App\Answer::create(['description' => 'George Harrison', 'is_correct' => false, 'question_id' => 5]);
     App\Answer::create(['description' => 'Keith Richards', 'is_correct' => true, 'question_id' => 5]);
     App\Answer::create(['description' => 'Ringo Starr', 'is_correct' => false, 'question_id' => 5]);
     App\Answer::create(['description' => 'Big in Japan', 'is_correct' => false, 'question_id' => 6]);
     App\Answer::create(['description' => 'I heard love is blind', 'is_correct' => false, 'question_id' => 6]);
     App\Answer::create(['description' => 'Smells like teen spirit', 'is_correct' => true, 'question_id' => 6]);
     App\Answer::create(['description' => 'Larry Page', 'is_correct' => false, 'question_id' => 7]);
     App\Answer::create(['description' => 'Peter Thiel', 'is_correct' => false, 'question_id' => 7]);
     App\Answer::create(['description' => 'Andrew Mason', 'is_correct' => true, 'question_id' => 7]);
     App\Answer::create(['description' => 'Richard Branson', 'is_correct' => false, 'question_id' => 7]);
     App\Answer::create(['description' => 'Tim Cook', 'is_correct' => false, 'question_id' => 7]);
 }
Example #4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // $this->call(UserTableSeeder::class);
     App\Quiz::create(['user_id' => 1, 'name' => 'The awesome quiz', 'desc' => 'Get ready to embark on the best quiz, OF YOUR LIFE!']);
     App\Question::create(['quiz_id' => 1, 'question_type_id' => 1, 'title' => 'Who wrote this wonderful Quiz?', 'time_limit' => 10000]);
     App\Answer::create(['question_id' => 1, 'answer_type_id' => 1, 'text' => 'Shane', 'value' => 1, 'correct' => true]);
     App\Answer::create(['question_id' => 1, 'answer_type_id' => 1, 'text' => 'Bob', 'value' => 1, 'correct' => false]);
     App\Answer::create(['question_id' => 1, 'answer_type_id' => 1, 'text' => 'Jordan', 'value' => 1, 'correct' => true]);
     App\Answer::create(['question_id' => 1, 'answer_type_id' => 1, 'text' => 'Uncle Sam', 'value' => 1, 'correct' => false]);
     Model::reguard();
 }
 public function postFeedbacksSave(Request $request)
 {
     $this->validate($request, ['fid' => 'required|exists:feedbacks,id', 'editor' => 'required'], ['editor.required' => 'Укажите ответ на отзыв']);
     $feedback = \App\Feedback::findOrFail($request->input('fid'));
     $answer = $feedback->answer;
     if (!$answer) {
         $answer = new \App\Answer();
         $answer->feedback_id = $feedback->id;
     }
     $answer->read_at = null;
     $answer->text = $request->input('editor');
     $answer->save();
     return redirect('admin/feedbacks');
 }