當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Question::where方法代碼示例

本文整理匯總了PHP中app\Question::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP Question::where方法的具體用法?PHP Question::where怎麽用?PHP Question::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Question的用法示例。


在下文中一共展示了Question::where方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     if (!Auth::check()) {
         return redirect('home')->with('message', "Veuillez d'abord vous connecter");
     }
     $question = Question::find($id);
     if (is_null($question)) {
         abort(404);
     }
     $total_questions = Question::count();
     $user = Auth::user();
     $total_questions_replied = $user->questionsReplied()->count();
     $total_questions_replied_percent = round($total_questions_replied / $total_questions * 100);
     // Get the current user that will be the origin of our operations
     // Get ID of a User whose autoincremented ID is less than the current user, but because some entries might have been deleted we need to get the max available ID of all entries whose ID is less than current user's
     $previousQuestionID = Question::where('id', '<', $question->id)->max('id');
     // Same for the next user's id as previous user's but in the other direction
     $nextQuestionID = Question::where('id', '>', $question->id)->min('id');
     $replies = $question->getChoices();
     // if user already replied to this particular question
     if ($question->getAnswer()) {
         $replies[$question->getAnswer()]['checked'] = true;
         $question->replied = true;
     }
     return view('questions.show', compact('question', 'previousQuestionID', 'nextQuestionID', 'replies', 'total_questions', 'total_questions_replied', 'total_questions_replied_percent'));
 }
開發者ID:philippejadin,項目名稱:mooc,代碼行數:32,代碼來源:QuestionsController.php

示例2: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $year = date('Y');
     $month = date('n');
     $day = date('j');
     $question = Question::where('year', $year)->where('month', $month)->where('day', $day)->first();
     if (count($question)) {
         $leagues = League::where('year', $question->leagueYear())->where('month', $question->leagueMonth())->get();
         foreach ($leagues as $key => $league) {
             $players = json_decode($league->users);
             foreach ($players as $key => $player) {
                 $user = User::find($player);
                 if ($user->deadline_reminder && $user->active) {
                     $answers = Answer::where('question_id', $question->id)->where('user_id', $user->id)->first();
                     if (!count($answers)) {
                         Mail::send('emails.deadlinereminder', [], function ($message) use($user) {
                             $message->from('no-reply@quizportugal.pt', 'Liga Quiz Portugal');
                             $message->to($user->email, $user->fullName())->subject('Quiz ainda não respondido');
                         });
                     }
                 }
             }
         }
     }
 }
開發者ID:andremiguelaa,項目名稱:liga-quiz,代碼行數:30,代碼來源:DeadlineReminder.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $student = Auth::user();
     $course_id = $request["course_id"];
     $questions = Question::where('course_id', '=', $course_id)->get();
     if (count($questions) <= 0) {
         Flash::error('There was a problem processing your request.');
         return redirect()->route('registration.index');
     }
     $question_count = 0;
     $passed_count = 0;
     foreach ($questions as $que) {
         $question_count = $question_count + 1;
         $keyword_found = 0;
         $answer_array = explode(',', $que->answers);
         $students_reply_array = explode(' ', $request[$que->id]);
         $students_reply = $request[$que->id];
         foreach ($answer_array as $keyword) {
             if (strpos($students_reply, $keyword) !== false) {
                 $keyword_found = $keyword_found + 1;
             }
         }
         if ($keyword_found == count($answer_array)) {
             $passed_count = $passed_count + 1;
         }
     }
     $percent = $passed_count / $question_count * 100;
     Exam::create(['course_id' => $course_id, 'student_id' => $student->id, 'score_percentage' => $percent]);
     Flash::success('Answer sheet submitted successfully.');
     return redirect()->route('registration.index');
 }
開發者ID:omoprodigi,項目名稱:Keyword-Matching-Exam,代碼行數:37,代碼來源:ExaminationController.php

示例4: getQuesitions

 public function getQuesitions(Request $request)
 {
     $type = $request->get('type');
     switch ($type) {
         case 0:
             $questions = Question::take(10)->get();
             break;
         case 1:
             $questions = Question::orderBy('total_answer', 'desc')->take(10)->get();
             break;
         case 2:
             $questions = Question::where('issolved', 0)->take(10)->get();
             break;
         default:
             $questions = Question::where('issolved', 1)->take(10)->get();
             break;
     }
     if ($questions) {
         foreach ($questions as &$question) {
             $question['time'] = $question->created_at->diffForHumans();
             $question['username'] = $question->user->name;
         }
         $this->setResult($questions);
         $this->succeed(true);
     } else {
         $this->setResult('questions表獲取記錄失敗!');
         $this->fail(true);
     }
 }
開發者ID:Panfen,項目名稱:mango,代碼行數:29,代碼來源:ForumController.php

示例5: deleteQuestions

 /**
  * @param $questionerId
  */
 public static function deleteQuestions($questionerId)
 {
     $question = Question::where('questioner_id', '=', $questionerId)->get();
     foreach ($question as $q) {
         $q->delete();
     }
 }
開發者ID:namilaRadith,項目名稱:AmalyaReach,代碼行數:10,代碼來源:Question.php

示例6: fetchStepQuestions

 protected function fetchStepQuestions($step)
 {
     $questions = Question::where('step', $step)->get();
     if (empty($questions)) {
         abort(404);
     }
     return $questions;
 }
開發者ID:blick36T,項目名稱:mtenancy,代碼行數:8,代碼來源:SurveyController.php

示例7: index

 public function index()
 {
     $where["questions.question_type"] = 2;
     $data['public_questions'] = Question::GetActiveQuestions($where)->take(3);
     $where["questions.question_type"] = 1;
     $data['private_questions'] = Question::GetActiveQuestions($where)->take(3);
     $data['archived_questions'] = Question::where("active", 0)->get()->take(3);
     return view('home', $data);
 }
開發者ID:panicfilip,項目名稱:Horizon-Polls,代碼行數:9,代碼來源:WelcomeController.php

示例8: create

 /**
  * Show the form for creating a new resource.
  *
  * @param Request $request
  * @return $this
  */
 public function create(Request $request)
 {
     if ($request->has('question')) {
         $questions = Question::findOrFail($request->get('question'))->unit->questions->lists('title', 'id');
     } else {
         $questions = Question::where('user_id', Auth::user()->id)->lists('title', 'id');
     }
     return view('teacher.answers.create')->with('questions', $questions)->with('title', trans('titles.create_new_answer'));
 }
開發者ID:jrafaelca,項目名稱:school_virtual,代碼行數:15,代碼來源:AnswersController.php

示例9: nextQuestionLink

 /**
  * Get the next question link (under the same questionnaire)
  * , return result page link if this is the final question.
  */
 public function nextQuestionLink()
 {
     $next = Question::where(['questionnaire_id' => $this->questionnaire_id, 'order' => $this->order + 1])->first();
     if ($next) {
         return '/questionnaires/' . $next->questionnaire_id . '/questions/' . $next->id;
     } else {
         return '/questionnaires/' . $this->questionnaire_id . '/questions/result';
     }
 }
開發者ID:Haolicopter,項目名稱:thug-election,代碼行數:13,代碼來源:Question.php

示例10: iresponse

 public function iresponse($project, Request $request)
 {
     $iresponseCol = Question::where('project_id', $project->id)->where('qnum', config('aio.iresponse'))->first();
     $dbraw = DB::select(DB::raw("SELECT pcode.state,answers.*,q.* \n            FROM pcode INNER JOIN results ON results.resultable_id = pcode.primaryid \n            INNER JOIN answers ON answers.status_id = results.id \n            INNER JOIN ( SELECT id,qnum FROM questions where id = '{$iresponseCol->id}') q ON q.id = answers.qid"));
     $dbGroupBy = DB::select(DB::raw("SELECT pcode.state,answers.*,q.* \n            FROM pcode INNER JOIN results ON results.resultable_id = pcode.primaryid \n            INNER JOIN answers ON answers.status_id = results.id \n            INNER JOIN ( SELECT id,qnum FROM questions where id = '{$iresponseCol->id}') q ON q.id = answers.qid GROUP BY results.id"));
     $incidents = Result::where('project_id', $project->id);
     $locations = PLocation::where('org_id', $project->org_id)->groupBy('state');
     return view('frontend.result.response-incident')->withProject($project)->withRequest($request)->withQuestion($iresponseCol)->withIncidents($incidents)->withLocations($locations)->withDbraw(collect($dbraw))->withDbGroup(collect($dbGroupBy));
 }
開發者ID:herzcthu,項目名稱:Laravel-HS,代碼行數:9,代碼來源:StatusController.php

示例11: QuestionGenerate

 public function QuestionGenerate(Request $request)
 {
     $class = $request->get('class');
     $subject = $request->get('subject');
     $partition = $request->get('partition');
     $questions = Question::where('class', '=', $class)->where('subject_id', '=', $subject)->where('partition_id', '=', $partition)->get();
     $questions[0]['token'] = $request->get("_token");
     return $questions;
 }
開發者ID:mish0501,項目名稱:exams,代碼行數:9,代碼來源:APIController.php

示例12: questions

 public static function questions()
 {
     if (Gate::allows('view_question')) {
         return Question::all();
     } elseif (Auth::check() && Gate::allows('view_own_question')) {
         return Question::where('user_id', Auth::id())->get();
     } else {
         return null;
     }
 }
開發者ID:jamesvillarrubia,項目名稱:mtc-api,代碼行數:10,代碼來源:GateCheck.php

示例13: search

 public function search(Request $request)
 {
     // retrieve query from URL
     $q = $request->q;
     // SQL LIKE format for matching on search query:
     // %SEARCH_TERM%
     $q_query = '%' . $q . '%';
     $questions = Question::where('title', 'LIKE', $q_query)->orWhere('description', 'LIKE', $q_query)->orWhere('code', 'LIKE', $q_query)->get();
     return view('questions.search', ['q' => $q, 'questions' => $questions, 'languages' => Language::all()]);
 }
開發者ID:alexpcoleman,項目名稱:fitl,代碼行數:10,代碼來源:QuestionController.php

示例14: search

 public function search(Request $request)
 {
     // Gets the search terms from our form submission
     $query = Request::input('search');
     $result = Question::where('title', 'LIKE', '%' . $query . '%')->orWhere('body', 'LIKE', '%' . $query . '%');
     // Paginate the questions
     $questions = $result->paginate(10);
     // returns a view and passes the view the list of questions and the original query.
     return view('search.results', compact('questions', 'query'));
 }
開發者ID:samchurney,項目名稱:teacherspet,代碼行數:10,代碼來源:QueryController.php

示例15: index

 public function index()
 {
     $user = JWTAuth::parseToken()->authenticate();
     $user_id = $user->id;
     $answers = Answer::where('user_id', $user_id)->get();
     //add the question to each answer
     for ($i = 0; $i < count($answers); $i++) {
         array_add($answers[$i], 'question', Question::where('id', $answers[$i]->question_id)->get());
     }
     return response()->json(['answers' => $answers]);
 }
開發者ID:jubaedprince,項目名稱:nohunchAPI,代碼行數:11,代碼來源:AnswerController.php


注:本文中的app\Question::where方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。