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


PHP app\Question类代码示例

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


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

示例1: 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

示例2: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Question $question)
 {
     $delete = $question->delete();
     if ($delete) {
         return 0;
     } else {
         return 1;
     }
 }
开发者ID:gugundwipermana,项目名称:laravel-serviceac,代码行数:15,代码来源:QuestionsController.php

示例3: 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

示例4: syncTags

 /**
  * Sync up the list of tags in the database.
  *
  * @param Article $article
  * @param array   $tags
  */
 private function syncTags(Question $question, array $tags)
 {
     // Create new tags if needed and get ids
     $tagIds = [];
     foreach ($tags as $tag) {
         $tagId = Tag::firstOrCreate(['name' => mb_strtolower($tag, 'UTF-8')])->id;
         $tagIds[] = $tagId;
     }
     // Sync tags based on ids
     $question->tags()->sync($tagIds);
 }
开发者ID:nilstr,项目名称:stackoverflow-clone,代码行数:17,代码来源:QuestionsController.php

示例5: 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

示例6: testShowQuestion

 public function testShowQuestion()
 {
     $survey = new Survey(['title' => 'Testing survey']);
     $question = new Question(['body' => 'What is this?', 'kind' => 'voice']);
     $survey->save();
     $question->survey()->associate($survey)->save();
     $response = $this->call('GET', route('question.show', ['id' => $question->id]));
     $savingUrl = route('question.question_response.store', ['question_id' => $question->id], false);
     $absoluteSavingUrl = route('question.question_response.store', ['question_id' => $question->id]);
     $this->assertContains($question->body, $response->getContent());
     $this->assertContains($savingUrl . '?Kind=voice', $response->getContent());
     $this->assertNotContains($absoluteSavingUrl, $response->getContent());
 }
开发者ID:illuminate3,项目名称:automated-survey-laravel,代码行数:13,代码来源:QuestionControllerTest.php

示例7: store

 public function store(Request $request, $idTraj)
 {
     $question = new Question();
     $libQuest = $request->question;
     $question->libQuest = $libQuest;
     $question->trajet()->associate(Trajet::find($idTraj));
     $question->save();
     $trajet = Trajet::find($question->idTraj);
     $data = array("question" => $question->libQuest, "idTraj" => $question->idTraj, "mailCond" => $trajet->user->email, "nomCond" => $trajet->user->prenomMemb);
     Mail::send('recherche.question.email', $data, function ($message) use($trajet, $question) {
         $message->to($trajet->user->email, $trajet->user->prenomMemb)->subject('Vous avez reçu une question !');
     });
     return redirect()->route('detailRecherche', $idTraj);
 }
开发者ID:julie-ramadanoski,项目名称:univoiturage,代码行数:14,代码来源:QuestionController.php

示例8: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $json = Storage::get('questions.json');
     $this->command->info($json);
     $questions = json_decode($json, true);
     foreach ($questions['questions'] as $question_keys => $question) {
         $this->command->info("Adding Question: " . $question_keys . "...");
         if ($question["type"] != "true-false") {
             $answers = $question['answers'];
             unset($question['answers']);
         }
         $q = new Question($question);
         $q->save();
         foreach ($question as $question_attribute_name => $question_attribute_value) {
             $this->command->info($question_attribute_name);
         }
         if ($q->type == "true-false") {
             $this->command->info("Adding True/False Question...");
             $answer = $question['answer'];
             $aFalse;
             $aTrue;
             if (Answer::where('text', 'true')->count() >= 1) {
                 $aTrue = Answer::where('text', 'true')->first();
             } else {
                 $aTrue = new Answer(['text' => 'true']);
                 $aTrue->save();
             }
             if (Answer::where('text', 'false')->count() >= 1) {
                 $aFalse = Answer::where('text', 'false')->first();
             } else {
                 $aFalse = new Answer(['text' => 'false']);
                 $aFalse->save();
             }
             $q->answers()->save($aFalse, ['is_correct' => $answer ? 0 : 1]);
             $q->answers()->save($aTrue, ['is_correct' => $answer ? 1 : 0]);
         } else {
             $this->command->info("Adding answers...");
             $answer_ids = array();
             foreach ($answers as $answer_index => $answer) {
                 $this->command->info("Adding " . ($answer_index + 1) . "...");
                 $a = new Answer($answer);
                 $a->save();
                 $q->answers()->save($a, ['is_correct' => $answer['is_correct'] === "false" ? 0 : 1]);
             }
         }
         $this->command->info("");
     }
 }
开发者ID:sgomez118,项目名称:ASM-Software-Management,代码行数:53,代码来源:QuestionSeeder.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('questions')->truncate();
     $quiz = new Question();
     $quiz->quiz_id = 1;
     $quiz->user_id = 1;
     $quiz->title = 'Seeded question 1';
     $quiz->save();
     $quiz = new Question();
     $quiz->quiz_id = 1;
     $quiz->user_id = 1;
     $quiz->title = 'Seeded question 2';
     $quiz->save();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
开发者ID:siderate,项目名称:banana-api,代码行数:21,代码来源:QuestionTableSeeder.php

示例10: add

 public function add(Request $request, $code)
 {
     $j = 0;
     $answer = '';
     $answer_corrected = '';
     for ($i = 1; $i <= count($request->input('variants')); $i++) {
         if ($j < count($request->input('answers'))) {
             if ($request->input('answers')[$j] == $i) {
                 $answer = $answer . ';' . "1";
                 $j++;
             } else {
                 $answer = $answer . ';' . "0";
             }
         } else {
             $answer = $answer . ';' . "0";
         }
     }
     $answer[0] = '';
     echo strlen($answer);
     for ($i = 1; $i < strlen($answer); $i++) {
         $answer_corrected = $answer_corrected . $answer[$i];
     }
     echo strlen($answer_corrected);
     $title = $request->input('variants')[0];
     for ($i = 1; $i < count($request->input('variants')); $i++) {
         $title = $title . ';' . $request->input('variants')[$i];
     }
     Question::insert(array('code' => $code, 'title' => $title, 'variants' => '', 'answer' => $answer_corrected, 'points' => $request->input('points')));
 }
开发者ID:mrudanov,项目名称:uirSV,代码行数:29,代码来源:YesNo.php

示例11: 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

示例12: questions

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

示例13: index

 public function index()
 {
     $questions = Question::all();
     $tpl['user'] = \Auth::user();
     $tpl['questions'] = $questions;
     return view('home', $tpl);
 }
开发者ID:bhasunjaya,项目名称:askpeople,代码行数:7,代码来源:HomeController.php

示例14: 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

示例15: testStoreResponse

 public function testStoreResponse()
 {
     $survey = new Survey(['title' => 'Testing survey']);
     $questionOne = new Question(['body' => 'What is this?', 'kind' => 'voice']);
     $questionTwo = new Question(['body' => 'What is that?', 'kind' => 'voice']);
     $survey->save();
     $questionOne->survey()->associate($survey)->save();
     $questionTwo->survey()->associate($survey)->save();
     $responseForQuestion = ['RecordingUrl' => '//somefake.mp3', 'CallSid' => '7h1515un1qu3', 'Kind' => 'voice'];
     $firstResponse = $this->call('POST', route('question.question_response.store', ['question_id' => $questionOne->id]), $responseForQuestion);
     $routeToNextQuestion = route('question.show', ['id' => $questionTwo->id], false);
     $routeToNextQuestionAbsolute = route('question.show', ['id' => $questionTwo->id], true);
     $this->assertContains($routeToNextQuestion, $firstResponse->getContent());
     $secondResponse = $this->call('POST', route('question.question_response.store', ['question_id' => $questionTwo->id]), $responseForQuestion);
     $this->assertNotContains('Redirect', $secondResponse->getContent());
 }
开发者ID:illuminate3,项目名称:automated-survey-laravel,代码行数:16,代码来源:QuestionResponseControllerTest.php


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