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


PHP Question::whereIn方法代码示例

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


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

示例1: getListQuestion

 /**
  * @return Collection
  */
 function getListQuestion()
 {
     $details = $this->details;
     $listIDQuestion = $details->lists('id_question');
     $listIDQuestion = array_unique($listIDQuestion);
     $questions = Question::whereIn('id', $listIDQuestion)->get();
     return $questions;
 }
开发者ID:phucps89,项目名称:Tour,代码行数:11,代码来源:Advice.php

示例2: function

        $sets = Set::valid()->get();
        $res = $app->response();
        $res['Content-Type'] = 'application/json';
        $res->body($sets);
    });
    $app->get('/:id', function ($id) use($app) {
        //      $set = Set::find($id);
        $ids = explode(';', $id);
        $set = Set::whereIn('id', $ids)->get();
        $res = $app->response();
        $res['Content-Type'] = 'application/json';
        $res->body($set);
    });
    $app->get('/:id/questions', function ($id) use($app) {
        $ids = explode(';', $id);
        $questions = Question::whereIn('set_id', $ids)->get();
        $questions->load('answers');
        $res = $app->response();
        $res['Content-Type'] = 'application/json';
        $res->body($questions);
    });
});
$app->group('/question(s)', function () use($app) {
    $app->get('/', function () use($app) {
        $questions = Question::with('answers')->get();
        $res = $app->response();
        $res['Content-Type'] = 'application/json';
        $res->body($questions);
    });
    $app->get('/:id', function ($id) use($app) {
        $question = Question::with('answers')->find($id);
开发者ID:guillepb,项目名称:empollon,代码行数:31,代码来源:index.php

示例3: emergencyUse

    public function emergencyUse()
    {
        //for($i=0;$i<10;$i++)
        //{
        ini_set('max_execution_time', 1000);
        $start = microtime(true);
        $userIds = array();
        $users = DB::select(DB::raw("select * from users where role!='admin_dd' and role!='sales_dd' and batchUpdate=2 Limit 10"));
        // $users = User::where('role','!=','admin_dd')->orWhere('role','!=','sales_dd')->orderby('name')->get();
        $userQuestion = array();
        $count = 1;
        foreach ($users as $user) {
            $userEvent_tmp[] = $user->event;
            $userIds[] = $user->id;
        }
        if (count($userIds) < 1) {
            dd("No User to be updated");
        }
        $userEvent = array_unique($userEvent_tmp);
        $questions_tmp = Question::whereIn('event', $userEvent)->get();
        $answerpair = Answer::whereIn('user_id', $userIds)->get();
        foreach ($questions_tmp as $question) {
            $userQuestionx[$question->event][] = $question;
        }
        foreach ($answerpair as $answer) {
            $userAnswers[$answer->question_id][] = $answer->user_id;
        }
        // $result = DB::select(DB::raw("select user_id,question_id from answers where  "));
        foreach ($users as $user) {
            foreach ($userQuestionx[$user->event] as $question) {
                // foreach($users as $user)
                $userQuestion[] = array($question->id, $user->id);
            }
        }
        $updated = false;
        foreach ($userQuestion as $pairval) {
            $answerx = new Answer();
            ?>
<div style="margin-bottom:30px;background:pink"><?php 
            if (!array_key_exists($pairval[0], $userAnswers)) {
                echo "<div style='background:yellow'>The Question answer is updated</div><br/>";
                $answerx->question_id = $pairval[0];
                $answerx->user_id = $pairval[1];
                $answerx->answer_text = '';
                //$answerx->save;
                //DB::select(DB::raw("insert into updatedanswertable (`questionid`,`userid`) values ('$pairval[0]','$pairval[1]') "));
                DB::select(DB::raw("insert into answers (`question_id`,`user_id`,`answer_text`) values ('{$pairval['0']}','{$pairval['1']}','') "));
                echo $pairval[0] . ",";
                echo $pairval[1] . "<br/>";
                $updated = true;
            } else {
                echo "The Question answer pair is already there<br/>";
                echo $pairval[0] . ",";
                echo $pairval[1] . "<br/>";
                $updated = true;
            }
            ?>
</div><?php 
            if ($updated == true) {
                DB::select(DB::raw("update users set batchUpdate=12 where id='{$pairval['1']}' "));
            }
        }
        $total = microtime(true) - $start;
        echo "Time to execute :" . $total;
        //sleep(10 * 60);
        //}
    }
开发者ID:harshithanaiduk,项目名称:ideconnect_2016,代码行数:67,代码来源:AdminController.php

示例4: main

 public function main()
 {
     $defaultQuestions = Question::whereIn('id', [1, 2, 3, 4])->get();
     return View::make('home.main', compact('defaultQuestions'));
 }
开发者ID:phucps89,项目名称:Tour,代码行数:5,代码来源:HomeController.php

示例5: view

 function view($id, $idQuestion = null)
 {
     if ($idQuestion == null) {
         $adviceDetails = AdviceDetail::where('id_advice', $id)->get();
         $listHistory = Question::whereIn('id', array_diff($adviceDetails->lists('id_question'), Question::$_rootQuestionID))->get();
         if (array_unique($adviceDetails->lists('id_question')) == Question::count()) {
             return View::make('advice.view', ['select' => 'next', 'question' => null, 'listHistory' => $listHistory, 'id' => $id, 'tours' => []]);
         }
         if ($adviceDetails->count() == 0) {
             return Redirect::route('advice.view', ['id' => $id, 'idQuestion' => 'root']);
         } else {
             $adviceDetails = AdviceDetail::where('id_advice', $id)->get();
             //=============
             $questionAnswerLoc = AdviceDetail::where('id_advice', $id)->where('id_question', 1)->first();
             $location = Location::join(Answer::getTableName(), Answer::getTableName() . '.name', '=', Location::getTableName() . '.code')->where(Answer::getTableName() . '.id', $questionAnswerLoc->id_answer)->select(Location::getTableName() . '.*')->first();
             $tours = Tour::where('start_loc', $location->id)->get();
             $listAnsOfNotFactor = $adviceDetails->filter(function ($row) {
                 return !in_array($row->id_question, Question::$_rootQuestionID);
             });
             if ($listAnsOfNotFactor->count() > 0) {
                 $arrAnsPoint = $this->scoreAnswer($listAnsOfNotFactor->lists('id_answer'));
                 $arrAnsPoint = $this->interaction($arrAnsPoint);
                 $idAttrForNext = $this->getAttributeForNext($arrAnsPoint);
                 if ($idAttrForNext) {
                     $listIDQuestionHistory = $adviceDetails->lists('id_question');
                     $strAvoid = implode(',', $listIDQuestionHistory);
                     $questionForNext = DB::select("\n                            SELECT `questions`.*\n                            FROM `questions`\n                            INNER JOIN `question_answer`\n                            ON `questions`.`id` = `question_answer`.`id_question`\n                            INNER JOIN `answers`\n                            ON `question_answer`.`id_answer` = `answers`.`id`\n                            WHERE `answers`.`id_attribute` = {$idAttrForNext}\n                            AND `questions`.`id` NOT IN ({$strAvoid})\n                            GROUP BY `question_answer`.`id_question`\n                            ORDER BY COUNT(DISTINCT `question_answer`.`id_answer`) DESC\n                        ")[0];
                     $question = new Question((array) $questionForNext);
                 }
             } else {
                 $question = Question::find(5);
             }
             return View::make('advice.view', ['select' => 'next', 'question' => $question, 'listHistory' => $listHistory, 'id' => $id, 'tours' => $tours]);
         }
     } else {
         if ($idQuestion == 'root') {
             $questions = Question::whereIn('id', Question::$_rootQuestionID)->get();
             $listHistory = new Collection();
             return View::make('advice.view', ['select' => 'root', 'questions' => $questions, 'listHistory' => $listHistory, 'id' => $id]);
         } else {
             $question = Question::find($idQuestion);
             $adviceDetails = AdviceDetail::where('id_advice', $id)->get();
             $listHistory = Question::whereIn('id', array_diff($adviceDetails->lists('id_question'), array_merge(Question::$_rootQuestionID, [$idQuestion])))->get();
             return View::make('advice.view', ['select' => 'history', 'question' => $question, 'listHistory' => $listHistory, 'id' => $id]);
         }
     }
 }
开发者ID:phucps89,项目名称:Tour,代码行数:47,代码来源:AdviceController.php


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