protected function findAnswerListModel($answer_list_id) { $model = AnswerList::findOne($answer_list_id); return $model; }
/** * Finds the AnswerList model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return AnswerList the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = AnswerList::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
protected function findModelAnswerList($id) { $model = AnswerList::findOne($id); if (!$model) { throw new NotFoundHttpException('The requested page does not exist.'); } if ($model->status == 'clear') { return $model; } $query = AnswerList::find(['id' => $id])->with(['questionList' => function ($query) { $query->with('questions'); }])->joinWith(['answers' => function ($q) { $q->with(['question' => function ($q) { $q->with('answerVariants'); }]); }])->where(['questionlist_answer_list.id' => $id, 'questionlist_answers.answer_list_id' => $id]); $model = $query->one(); if ($model) { return $model; } else { throw new NotFoundHttpException('Не найдено.'); } }