/** * Update the specified resource in storage. * * @param Question $questions * @param CategoryRequest $request * @return Response */ public function update(Question $questions, QuestionRequest $request) { Session::put('questions_hash', md5(time())); $attachment = ImageUploadFacade::attachmentUpload($request->file('attachment'), new QuestionAttachment(), 'questions', true); $questions->fill($request->all())->questions_attachment()->associate($attachment); $questions->save(); return redirect()->route('admin.questions.index'); }
/** * Update the specified resource in storage. * * @param Question $questions * @param CategoryRequest $request * @return Response */ public function update(Question $questions, QuestionRequest $request) { $attachment = ImageUploadFacade::image($request->file('attachment')); $questions->fill($request->all()); if ($attachment) { $questions->attachment()->associate($attachment); } $questions->save(); return redirect()->route('admin.questions.index'); }
/** * Store a newly created resource in storage. * * @param QuestionRequest $request * @return \Illuminate\Http\Response */ public function store(QuestionRequest $request, ImageController $imageController) { $question = new Question($request->all()); $question['source'] = $request->source != null ? $request->source : Auth::user()->name; $question['question_image'] = $request->question_image != null ? $imageController->store(Input::file('question_image'), 'question_image', $question['id'], null) : null; for ($i = 0; $i < 4; $i++) { $image_field = 'answer' . $i . '_image'; $question[$image_field] = $request[$image_field] != null ? $imageController->store($request->file($image_field), 'answer' . $i . '_image', $question['id'], null) : null; } Auth::user()->questions()->save($question); flash('Question created.This is how your question will look like:'); return redirect('questions/' . $question->id); }