Example #1
0
 public function update(AnswerRequest $request, int $id)
 {
     $answer = Answer::findOrFail($id);
     $this->authorize('edit-answer', $answer);
     $answer->body = $request->get('body');
     $answer->save();
     session()->flash('success', 'La respuesta ha sido editada.');
     return redirect()->route('question.show', $answer->question->id);
 }
 /**
  * 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();
 }
 public function storeAnswer($id, AnswerRequest $request)
 {
     if ($request->input('to_message') == $id) {
         Answer::create(['answer' => $request->input('answer'), 'user_id' => \Auth::id(), 'user_name' => \Auth::user()->name, 'to_message' => $request->input('to_message')]);
         flash()->success('Wiadomość prywatna została wysłana!');
         return redirect('/private/' . $request->input('to_message') . '');
     } else {
         return 'Oszust!';
     }
 }
 public function store(AnswerRequest $request)
 {
     $client = Client::create();
     //Was macht hier das ->all();
     $questionData = $request->all();
     foreach ($questionData["radio_question"] as $question => $value) {
         $answer = new Answer();
         $answer->question_id = $question;
         $answer->answer = $value;
         $answer->client_id = $client->id;
         //Unterschied zwischen ->save und ::create
         $answer->save();
     }
     //Kann man das irgendwie sauberer lösen als mit dieser foreach Schleife, damit es DRY-Kompatibel ist?
     foreach ($questionData["text_question"] as $question => $value) {
         $answer = new Answer();
         $answer->question_id = $question;
         $answer->comment = $value;
         $answer->client_id = $client->id;
         //Unterschied zwischen ->save und ::create
         $answer->save();
     }
 }
 public function updateAnswer(AnswerRequest $request, Answer $answer)
 {
     $input = $request->all();
     $application = Application::find($input['application_id']);
     if ($answer->user->id != Auth::user()->id) {
         $request->session()->flash('error', 'Only the person who created an application may answer questions for it.');
         return redirect('/login');
     }
     if ($answer->application->status != 'new') {
         $request->session()->flash('error', 'Your application has been submitted, you may no longer make changes.');
         return redirect('/applications/' . $application->id . '/review');
     }
     $answer->update($input);
     // Check if a file needs to be uploaded
     if ($answer->question->type == 'file') {
         // Save uploaded file
         $upload = Document::handleUpload($request);
         // Save new document
         Document::createDocument($application, $upload, $answer);
     }
     $request->session()->flash('success', 'Your answer has been saved.');
     return redirect('/applications/' . $answer->application->id);
 }
 /**
  * @param $slug
  */
 public function answer(AnswerRequest $request, $slug)
 {
     $question = $this->question->findOrFail($request->question_id);
     $question->answer = $request->answer;
     $question->save();
     $request->user()->xp = $request->user()->xp + 20;
     $request->user()->save();
     return back()->withNotification("Success! Question has been answered.")->withType('success');
 }