/** * Finds the Discipline model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Discipline the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Discipline::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionTeacher_by_cathedra($id) { $cathedra_id = Discipline::findOne(['discipline_distribution_id' => $id]); $countPosts = Teachers::find()->where(['id_cathedra' => $cathedra_id['id_cathedra']])->count(); $posts = Teachers::find()->where(['id_cathedra' => $cathedra_id['id_cathedra']])->orderBy('teacher_name ASC')->all(); if ($countPosts > 0) { echo "<option>Оберіть викладача</option>"; foreach ($posts as $post) { echo "<option value='" . $post->teacher_id . "'>" . $post->teacher_name . "</option>"; } } else { echo "<option>-</option>"; } }
function getDisciplineType($id_discipline) { $disc_info = Discipline::findOne(['discipline_distribution_id' => $id_discipline]); $discipline_type = LessonsType::findOne(['id' => $disc_info['id_lessons_type']]); return $discipline_type['lesson_type_name']; }