当前位置: 首页>>代码示例>>PHP>>正文


PHP Question::save方法代码示例

本文整理汇总了PHP中app\Question::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::save方法的具体用法?PHP Question::save怎么用?PHP Question::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Question的用法示例。


在下文中一共展示了Question::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addquestions

 public function addquestions()
 {
     $data = Input::all();
     $event = Event::where('id', Session::get('event_id'))->first();
     $question = new Question();
     $question->event_id = Session::get('event_id');
     $question->question = $data['question'];
     $image = array();
     if (isset($data['file'])) {
         if (Input::file('file')->isValid()) {
             $destinationPathvfile = 'uploads';
             $extensionvfile = Input::file('file')->getClientOriginalExtension();
             $fileNamevfile = $event->id . '.' . $extensionvfile;
             // renaming image
             Input::file('file')->move($destinationPathvfile, $fileNamevfile);
             $question->image = $fileNamevfile;
         }
     }
     if (isset($data['html'])) {
         $question->html = $data['html'];
     }
     if (intval($event->type) > 2) {
         $question->options = serialize($data['options']);
         $answers = $data['answers'];
         $question->save();
         Session::put('qid', Question::all()->last()->id);
         foreach ($answers as $ans) {
             $answer = new Answer();
             $answer->ques_id = Session::get('qid');
             $answer->answer = $ans;
             $answer->score = 1;
             $answer->incorrect = 0;
             $answer->save();
         }
     } else {
         $question->level = $data['level'];
         $question->save();
         Session::put('qid', Question::all()->last()->id);
         $answer = new Answer();
         $answer->ques_id = Session::get('qid');
         $answer->answer = $data['answer'];
         $answer->score = 1;
         $answer->incorrect = 0;
         $answer->save();
     }
     Session::put('event_id', $event->id);
     return Redirect::route('viewquestions', ['event_id' => $event->id])->with('message', 'Question Successfully Added');
 }
开发者ID:ncs-jss,项目名称:elastic-heart,代码行数:48,代码来源:QuestionsController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $question = new Question($request->all());
     $question->order = $question->questionable->questions->count() > 0 ? $question->questionable->questions->sortByDesc('order')->first()->order + 1 : 1;
     $question->save();
     return redirect($question->questionable->route());
 }
开发者ID:slipperydippery,项目名称:question,代码行数:13,代码来源:QuestionsController.php

示例3: question

 public function question(Request $request)
 {
     $massages = ['required' => ':attribute กรุณาระบุข้อมูลให้ครบถ้วน!'];
     $validator = Validator::make($request->all(), ['title' => 'required', 'detail' => 'required'], $massages);
     if ($validator->fails()) {
         if ($request->get('redirect') == '') {
             return redirect(route('home'))->withInput()->withErrors($validator->errors());
         } else {
             return redirect(html_entity_decode($request->get('redirect')))->withInput()->withErrors($validator->errors());
         }
     }
     $questionSave = new Question();
     $questionSave->memberId = Auth::user()->id;
     $questionSave->subId = $request->get('subId');
     $questionSave->title = trim($request->get('title'));
     $questionSave->detail = trim($request->get('detail'));
     $questionSave->save();
     $log = new Log();
     $log->memberId = Auth::user()->id;
     $log->detail = 'Post,' . $questionSave;
     $log->save();
     //dd($request->get('redirect'));
     if ($request->get('redirect') == '') {
         return redirect(route('home'));
     } else {
         return redirect(html_entity_decode($request->get('redirect')));
     }
 }
开发者ID:komphet5139,项目名称:ubr,代码行数:28,代码来源:Home.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $questions = new Question();
     $questions->question = 'Kan du baka?';
     $questions->points = '5';
     $questions->type = '1';
     $questions->save();
 }
开发者ID:Cap-y,项目名称:ImperierumChallenge,代码行数:14,代码来源:QuestionController.php

示例5: getQuestionAdd

 /**
  * Responds to request to GET /question/add/{quiz_id}
  */
 public function getQuestionAdd($quiz_id)
 {
     $quiz = Quiz::find($quiz_id);
     $question = new Question();
     $question->quiz_id = $quiz_id;
     $question->save();
     return redirect('/question/edit/' . $question->id);
 }
开发者ID:philipjamesk,项目名称:p4,代码行数:11,代码来源:QuestionController.php

示例6: store

 public function store(QuestionFormRequest $request)
 {
     //return $request->all();
     $slug = uniqid();
     $question = new Question(array('question' => $request->get('question'), 'option1' => $request->get('option1'), 'option2' => $request->get('option2'), 'option3' => $request->get('option3'), 'option4' => $request->get('option4'), 'slug' => $slug));
     $question->save();
     return redirect('create')->with('status', 'Your question has been saved! Its unique id is: ' . $slug);
 }
开发者ID:iqrasadra,项目名称:Project,代码行数:8,代码来源:QuestionsController.php

示例7: postCreateAQuestion

 public function postCreateAQuestion(Request $request)
 {
     $question = new Question();
     $question->user_id = \Auth::user()->id;
     $question->title = $request->title;
     $question->slug = str_slug($request->title, "-");
     $question->save();
     return redirect('/questions');
 }
开发者ID:barantr90,项目名称:resmin-laravel,代码行数:9,代码来源:QuestionsController.php

示例8: saveQuestion

 public function saveQuestion()
 {
     $input = Input::all();
     if (!empty($input['questionid'])) {
         $question = Question::find($input['questionid']);
     } else {
         $question = new Question();
     }
     $question->exam = $input['exam'];
     $question->body = $input['examtitle'];
     $question->choices = json_encode($input['choices']);
     if (!empty($input['questionid'])) {
         $question->save();
     } else {
         $question->save();
     }
     return redirect()->intended('/assessment/exams/' . $input['examcode'] . '/edit');
 }
开发者ID:ralphjesy12,项目名称:cdts,代码行数:18,代码来源:FormsController.php

示例9: postCreate

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate(QuestionRequest $request)
 {
     $question = new Question();
     $question->user_id = Auth::id();
     $question->country_id = Auth::user()->country_id;
     $question->question_category_id = $request->question_category_id;
     $question->content = $request->content;
     $question->save();
     return Redirect::action('HomeController@index');
 }
开发者ID:alex311982,项目名称:laravel5_online_support,代码行数:15,代码来源:QuestionsController.php

示例10: store_question

 public function store_question(Request $request)
 {
     $question = new Question();
     $question->content = $request->question_content;
     $question->type = $request->type;
     $question->survey_id = $request->survey_id;
     $question->order = $request->order;
     $question->save();
     return redirect('manage/survey/' . $question->survey_id);
 }
开发者ID:Kaelcao,项目名称:colormev2,代码行数:10,代码来源:SurveyController.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param CreateQuestionRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(CreateQuestionRequest $request)
 {
     $question = new Question();
     $question->fill($request->all());
     $question->user_id = Auth::user()->id;
     $question->save();
     $message = trans('messages.question_created_successfully');
     Flash::success($message);
     return redirect()->route('teacher.units.show', $question->unit);
 }
开发者ID:jrafaelca,项目名称:school_virtual,代码行数:16,代码来源:QuestionsController.php

示例12: store

 public function store(QuestionRequest $request)
 {
     $course = Course::findOrFail($request->input('course_id'));
     $this->authorize('view-course', $course);
     $question = new Question($request->only(['title', 'body']));
     $question->course()->associate($course);
     $question->user()->associate(auth()->user());
     $question->save();
     session()->flash('success', 'La pregunta ha sido enviada');
     return redirect()->back();
 }
开发者ID:abalozz,项目名称:glaciar,代码行数:11,代码来源:QuestionsController.php

示例13: addQuestions

 /**
  * add questions to database
  * @param $data
  * @param $questionerId
  */
 public static function addQuestions($data, $questionerId)
 {
     foreach ($data['Questions'] as $value) {
         //echo $value['question']." ".$value['questionType']."\n";
         $question = new Question();
         $question->question = $value['question'];
         $question->question_type = $value['questionType'];
         $question->questioner_id = $questionerId;
         $question->save();
     }
 }
开发者ID:namilaRadith,项目名称:AmalyaReach,代码行数:16,代码来源:Question.php

示例14: addTraining

 public function addTraining(Request $request)
 {
     $data = array('name' => htmlentities($request->input('title')), 'description' => htmlentities($request->input('description')), 'image' => $request->input('imagine'), 'areaType' => substr($request->input('arie'), 0, 1), 'area' => htmlentities(substr($request->input('arie'), 1)), 'locuri' => htmlentities($request->input('locuri')), 'ziua' => htmlentities($request->input('ziua')), 'ora' => htmlentities($request->input('ora')));
     $data['intrebari'] = array();
     $idIntrebare = 1;
     $intrebare = htmlentities($request->input('intrebare' . $idIntrebare));
     while (isset($intrebare)) {
         array_push($data['intrebari'], $intrebare);
         $idIntrebare++;
         $intrebare = $request->input('intrebare' . $idIntrebare);
     }
     $rules = array('name' => 'required', 'description' => 'required', 'image' => 'image', 'area' => 'exists:areas,id', 'subarea' => 'exists:subareas,id', 'locuri' => 'numeric|required', 'ziua' => 'required', 'ora' => 'required');
     if ($data['areaType'] == 's') {
         $data['subarea'] = $data['area'];
         $data['area'] = Subarea::where('id', $data['subarea'])->first()->area_id;
     } else {
         $data['subarea'] = "";
     }
     $validator = Validator::make($data, $rules);
     if (!$validator->fails()) {
         $training = new Training();
         $nameOfImage = $this->generateRandomString() . '.jpg';
         Storage::put('images/' . $nameOfImage, $data['image']);
         $training->trainer_id = Auth::user()->id;
         $training->name = $data['name'];
         $training->description = $data['description'];
         $training->image = "images/" . $nameOfImage;
         $training->area_id = $data['area'];
         $training->subarea_id = $data['subarea'];
         $training->locuri = $data['locuri'];
         $training->save();
         $group = new Group();
         $group->trainer_id = Auth::user()->id;
         $group->training_id = $training->id;
         $group->area_id = $training->area_id;
         $group->subarea_id = $training->subarea_id;
         $group->groupOrder = 1;
         $group->data = $data['ziua'];
         $group->ora = $data['ora'];
         $group->save();
         foreach ($data['intrebari'] as $intrebare) {
             $question = new Question();
             $question->training_id = $training->id;
             $question->question = $intrebare;
             $question->posted_by = Auth::user()->id;
             $question->required = 1;
             $question->save();
         }
         return redirect('/trainer');
     } else {
         return $data['areaType'];
     }
 }
开发者ID:StoianCatalin,项目名称:fiiPractic2016,代码行数:53,代码来源:TrainingController.php

示例15: ask

 public function ask(Request $request, $courseSlug, $lessonSlug)
 {
     $this->validate($request, ['question' => 'required']);
     $course = Course::where('slug', $courseSlug)->firstOrFail();
     $lesson = Lesson::where('slug', $lessonSlug)->where('course_id', $course->id)->firstOrFail();
     $question = new Question();
     $question->questioner_id = Auth::user()->id;
     $question->lesson_id = $lesson->id;
     $question->question = $request->question;
     $question->save();
     return redirect(action('LessonController@show', [$courseSlug, $lessonSlug]));
 }
开发者ID:joaopluis,项目名称:oldschool,代码行数:12,代码来源:LessonController.php


注:本文中的app\Question::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。