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


PHP Question::create方法代码示例

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


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

示例1: questions

 function questions()
 {
     $faker = Faker::create();
     foreach (range(0, 10) as $i) {
         Question::create(['body' => $faker->paragraph]);
     }
 }
开发者ID:bhasunjaya,项目名称:askpeople,代码行数:7,代码来源:DatabaseSeeder.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\CreateQuestionRequest $request)
 {
     $question = Question::create($request->all());
     //required answer
     $answer_description_1 = $request->answer_description_1;
     $answer_is_correct_1 = $request->answer_is_correct_1;
     $question->answers()->create(['description' => $answer_description_1, 'is_correct' => $answer_is_correct_1]);
     // required answer
     $answer_description_2 = $request->answer_description_2;
     $answer_is_correct_2 = $request->answer_is_correct_2;
     $question->answers()->create(['description' => $answer_description_2, 'is_correct' => $answer_is_correct_2]);
     // optional answer
     $answer_description_3 = $request->answer_description_3;
     $answer_is_correct_3 = $request->answer_is_correct_3;
     if (isset($answer_description_3) && isset($answer_is_correct_3)) {
         $question->answers()->create(['description' => $answer_description_3, 'is_correct' => $answer_is_correct_3]);
     }
     // optional answer
     $answer_description_4 = $request->answer_description_4;
     $answer_is_correct_4 = $request->answer_is_correct_4;
     if (isset($answer_description_4) && isset($answer_is_correct_4)) {
         $question->answers()->create(['description' => $answer_description_4, 'is_correct' => $answer_is_correct_4]);
     }
     \Session::flash('success', 'The question is successfully created.');
     return redirect('questions');
 }
开发者ID:phpclub,项目名称:GA-Exam,代码行数:31,代码来源:QuestionsController.php

示例3: store

 public function store(QuestionRequest $request)
 {
     $question = Request::only(['name', 'body']);
     $answers = Request::only(['answer_name', 'answer_info']);
     $my_question = Question::create($question);
     return redirect('questions');
 }
开发者ID:EricChristensen,项目名称:Laravel-Millionaire,代码行数:7,代码来源:QuestionsController.php

示例4: post_write

 public function post_write(Request $request)
 {
     $this->authorize('qna-write');
     $request->merge(['writer_id' => Auth::user()->id]);
     $q = Question::create($request->all());
     return redirect("qs/{$q->id}");
 }
开发者ID:smartbos,项目名称:qna,代码行数:7,代码来源:QController.php

示例5: store

 public function store(QuestRequest $request)
 {
     $quest = Question::create($request->all());
     $quest->section()->attach($request->input('section'));
     flash()->success('Twoje zapytanie zostało wysłane poprawnie, oczekuj odpowiedzi na swojej skrzynce pocztowej. Zazwyczaj trwa to do 24h, pozdrawiamy, ekipa PLERP!');
     return redirect('/');
 }
开发者ID:AdrianKuriata,项目名称:projekt,代码行数:7,代码来源:QuestController.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 100; $i++) {
         $question = \App\Question::create(['question' => $faker->text(300), 'option_1' => $faker->text(100), 'option_2' => $faker->text(100), 'option_3' => $faker->text(100), 'option_4' => $faker->text(100), 'answer' => $faker->numberBetween(1, 4), 'user_create' => $faker->numberBetween(1, 10)]);
     }
 }
开发者ID:nghesilangthang,项目名称:simple_quiz_admin,代码行数:12,代码来源:question.php

示例7: store

 public function store()
 {
     $input = Request::all();
     $article = Question::create($input);
     $article->user_id = Auth::user()->id;
     $article->save();
     return redirect('questions');
 }
开发者ID:jubaedprince,项目名称:incuba_php,代码行数:8,代码来源:QuestionsController.php

示例8: run

 /**
  * Run the question seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $users = User::all()->lists('id')->all();
     foreach (range(1, 20) as $index) {
         Question::create(['user_id' => $faker->randomElement($users), 'title' => $faker->sentence(10), 'body' => $faker->paragraph(5)]);
     }
 }
开发者ID:TerryKLin,项目名称:teacherspet,代码行数:13,代码来源:QuestionsTableSeeder.php

示例9: run

 public function run()
 {
     $faker = Faker\factory::create();
     DB::table('questions')->delete();
     foreach (range(1, 5) as $index) {
         Question::create(['question' => $faker->word, 'points' => $faker->numberBetween($min = 1, $max = 100), 'type' => $faker->numberBetween($min = 1, $max = 2)]);
     }
 }
开发者ID:Cap-y,项目名称:ImperierumChallenge,代码行数:8,代码来源:QuestionTableSeeder.php

示例10: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create('zh_TW');
     Question::truncate();
     //
     foreach (range(1, 1000) as $number) {
         Question::create(['stages_id' => $faker->randomElement($array = array('101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '201', '202', '203', '204', '205', '206', '207', '301', '302', '303', '304', '305', '401', '501', '601')), 'qtitle' => $number . $faker->text, 'ans1_title' => 'ans' . $number, 'ans2_title' => 'ans' . $number, 'ans3_title' => 'ans' . $number, 'ans4_title' => 'ans' . $number, 'ans5_title' => 'ans' . $number, 'ans6_title' => '放棄', 'answer' => rand(1, 5), 'detailed' => $faker->text, 'created_at' => Carbon\Carbon::now(), 'updated_at' => Carbon\Carbon::now()]);
     }
 }
开发者ID:a8212270,项目名称:QuizPlatFormWeb,代码行数:14,代码来源:QuestionSeeder.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required', 'description' => 'required']);
     //
     $input = $request->all();
     Question::create($input);
     Session::flash('flash_message', 'Question successfully added!');
     return redirect()->back();
 }
开发者ID:shrastisoni,项目名称:bul1,代码行数:14,代码来源:QuestionController.php

示例12: storeQuestion

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function storeQuestion()
 {
     $input = Request::all();
     $user = \Auth::user();
     $input['published_at'] = Carbon::now();
     $fiche_id = Session::get('fiche_id');
     $question = \App\Question::create($input);
     return view('back.newQuestion', compact('question', 'fiche_id', 'user'));
 }
开发者ID:Vever,项目名称:projetLycee2015,代码行数:14,代码来源:QuestionController.php

示例13: saveAllQuestions

 protected static function saveAllQuestions($questions, $test)
 {
     foreach ($questions as $question) {
         $savedQuestion = Question::create(['test_id' => $test->id, 'title' => $question['title']]);
         foreach ($question['options'] as $i => $option) {
             Option::create(['question_id' => $savedQuestion->id, 'value' => $option]);
         }
     }
 }
开发者ID:iamfaiz,项目名称:lahm,代码行数:9,代码来源:Test.php

示例14: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('questions')->delete();
     $questions = array(['question' => 'question1?', 'user_id' => 3], ['question' => 'question2?', 'user_id' => 2], ['question' => 'question3?', 'user_id' => 4], ['question' => 'question4?', 'user_id' => 1]);
     // Loop through each user above and create the record for them in the database
     foreach ($questions as $question) {
         Question::create($question);
     }
 }
开发者ID:jubaedprince,项目名称:nohunchAPI,代码行数:14,代码来源:CreateQuestionsTableSeeder.php

示例15: saveNewTest

 public function saveNewTest($test)
 {
     $newTest = Test::create(['name' => $test['name'], 'preparation' => $test['preparation'], 'time' => $test['time']]);
     // Nested loop to add questions > options
     foreach ($test['questions'] as $question) {
         $savedQuestion = Question::create(['test_id' => $newTest->id, 'title' => $question['title'], 'correct' => $question['correct']]);
         foreach ($question['options'] as $i => $option) {
             Option::create(['question_id' => $savedQuestion->id, 'value' => $option]);
         }
     }
 }
开发者ID:iamfaiz,项目名称:lahm,代码行数:11,代码来源:Tests.php


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