/** * 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'); }
/** * Save question to database * */ public function saveQuestion($data) { $question = new Question(); /*$question->title = $data['title'];*/ $question->text = $data['text']; $question->user_id = \Auth::user()->id; if (\Auth::user()->profile->city_id) { $question->city_id = \Auth::user()->profile->city_id; } $question->attachment_hash = Session::get('questions_hash'); $question->save(); }
/** * Display a listing of the resource. */ public function index() { if (\Auth::user() && \Auth::user()->profile->city_id != null) { $questions = Question::where('city_id', '=', \Auth::user()->profile->city_id)->orderBy('id', 'desc')->paginate(5); return view('questions::index', compact('questions')); } else { $questions = Question::orderBy('id', 'desc')->paginate(5); return view('questions::index', compact('questions')); } }