本文整理汇总了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));
}
示例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;
}
示例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);
}
示例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]);
}
示例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');
}