public function saveQuestion($PostID) { if (!AuthController::checkPermission()) { return redirect('/'); } $data = Request::capture(); $question = new Questions(); $question->PostID = $PostID; $question->ThumbnailID = $data['ThumbnailID']; $question->Question = $data['Question']; $question->Description = $data['Description']; switch ($data['ThumbnailID']) { case '1': // Photo $question->save(); $question = Questions::orderBy('id', 'desc')->first(); //Photo $file = Request::capture()->file('Photo'); if ($file != null) { $question->Photo = 'Question_' . $PostID . '_' . $question->id . "_-Evangels-English-www.evangelsenglish.com_" . "." . $file->getClientOriginalExtension(); $file->move(base_path() . '/public/images/imageQuestion/', $question->Photo); } $question->update(); break; case '2': // Video $linkVideo = $data['Video']; $question->Video = PostsController::getYoutubeVideoID($linkVideo); $question->save(); break; } echo $question->id; return; }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $questions = Questions::orderBy('id', 'desc')->paginate(10); $questions->setPath('QA'); return view('QA.index')->with('questions', $questions); }