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


PHP Question::max方法代码示例

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


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

示例1: index

 /**
  * The game page itself
  *
  * @return Response
  */
 public function index()
 {
     $ws = Websitespel::where("ended", false)->orderBy('start_date')->first();
     if ($ws == null) {
         //no games in progress and none planned
         //return done
         return view('game.ended')->with('countDown', false);
     } else {
         if ($ws->start_date > \Carbon\Carbon::now()) {
             // do the countdown
             // return countdown
             return view('game.countdown')->with('countDown', $ws);
         }
     }
     // else carry on
     $team = Auth::user()->team()->first();
     $questionNr = count(Progress::where('team_id', $team->id)->get());
     $question = null;
     $tip = false;
     $times = [];
     if ($questionNr != count(Question::all())) {
         $question = Question::where('sequence', $questionNr + 1)->first();
         $result = QuestionTime::where('team_id', $team->id)->where('question_id', $question->id)->get();
         if (count($result) == 0) {
             $questionTime = new QuestionTime();
             $questionTime->team_id = $team->id;
             $questionTime->question_id = $question->id;
             $questionTime->tip = false;
             $questionTime->start_time = \Carbon\Carbon::now()->timestamp;
             $questionTime->save();
             $tip = false;
         } else {
             $tip = $result->first()->tip;
         }
     } else {
         $teams = Team::all();
         $teamsCount = count($teams);
         $question_id = Question::where('sequence', Question::max('sequence'))->first()->id;
         for ($i = 0; $i < $teamsCount; $i++) {
             $qt = QuestionTime::where('team_id', $teams[$i]->id)->where('question_id', $question_id)->first();
             if ($qt == null) {
                 continue;
             }
             $end_time = $qt->end_time;
             if ($end_time == null) {
                 continue;
             }
             $end_time_string = \Carbon\Carbon::createFromTimestamp($end_time);
             array_push($times, array('name' => $teams[$i]->teamname, 'time' => $end_time_string, 'countDown' => 0));
         }
         usort($times, function ($a, $b) {
             return $a['time']->timestamp - $b['time']->timestamp;
         });
     }
     return view('game.index')->with(array('question' => $question, 'tip' => $tip, 'end_times' => $times, 'countDown', null));
 }
开发者ID:jvanraemdonck,项目名称:Websitespel,代码行数:61,代码来源:GameController.php

示例2:

 function __construct($id_question)
 {
     if ($id_question != Question::max('id_question') + 1) {
         //проверка не является ли вопрос новым
         $query = Question::whereId_question($id_question)->first();
         $this->text = $query->title;
         $this->variants = $query->variants;
         $this->answer = $query->answer;
         $this->points = $query->points;
     }
     $this->id_question = $id_question;
 }
开发者ID:mrudanov,项目名称:uirSV,代码行数:12,代码来源:QuestionType.php

示例3: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!($request->survey = Survey::find($request->session()->get('survey_id')))) {
         return redirect()->action('SurveyController@getSurvey');
     }
     $request->maxStep = Question::max('step');
     if ($request->survey->current_step > $request->maxStep) {
         return redirect()->action('SurveyController@getSurveyDone');
     } elseif ($request->route('step') > $request->survey->current_step) {
         return redirect()->action('SurveyController@getSurveyStep', ['step' => $request->survey->current_step]);
     }
     return $next($request);
 }
开发者ID:illuminate3,项目名称:multistep-tutorial,代码行数:20,代码来源:SurveyMiddleware.php

示例4: postSurveyStep

 public function postSurveyStep(Request $request, $step)
 {
     $questions = $this->fetchStepQuestions($step);
     $lastStep = Question::max('step');
     $rules = [];
     foreach ($questions as $question) {
         $rules[$question->name] = $question->rule;
     }
     $this->validate($request, $rules);
     $request->session()->get('survey')->update($request->only(array_keys($rules)));
     if ($step == $lastStep) {
         return redirect()->action('SurveyController@getSurveyDone');
     }
     return redirect()->action('SurveyController@getSurveyStep', ['step' => $step + 1]);
 }
开发者ID:blick36T,项目名称:mtenancy,代码行数:15,代码来源:SurveyController.php

示例5: add

 /** Обработка формы добавления вопроса */
 public function add(Request $request)
 {
     $code = $this->setCode($request);
     $type = $request->input('type');
     $query = Question::max('id_question');
     //пример использования агрегатных функций!!!
     $id = $query + 1;
     switch ($type) {
         case 'Выбор одного из списка':
             $one_choice = new OneChoice($id);
             $one_choice->add($request, $code);
             break;
         case 'Выбор нескольких из списка':
             $multi_choice = new MultiChoice($id);
             $multi_choice->add($request, $code);
             break;
         case 'Текстовый вопрос':
             $fill_gaps = new FillGaps($id);
             $fill_gaps->add($request, $code);
             break;
         case 'Таблица соответствий':
             $fill_gaps = new AccordanceTable($id);
             $fill_gaps->add($request, $code);
             break;
         case 'Да/Нет':
             $fill_gaps = new YesNo($id);
             $fill_gaps->add($request, $code);
             break;
         case 'Определение':
             $definition = new Definition($id);
             $definition->add($request, $code);
             break;
         case 'Просто ответ':
             $just = new JustAnswer($id);
             $just->add($request, $code);
             break;
         case 'Теорема':
             $theorem = new Theorem($id);
             $theorem->add($request, $code);
             break;
     }
     return redirect()->route('question_create');
 }
开发者ID:mrudanov,项目名称:uirSV,代码行数:44,代码来源:QuestionController.php


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