/** * 课程详细页面 * @param integer $id * @return mixed */ public function actionView($id) { $model = Course::findOne($id); // $dataProvider = new ActiveDataProvider([ // 'query' => $model->getVideos(), // ]); //var_dump(Course::getVideoList($model->id)); return $this->render('view', ['model' => $model, 'author' => $model->getAuthor(), 'chapters' => Course::getVideoList($model->id)]); }
/** * Finds the Course model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Course the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Course::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionArticle() { $aid = Yii::$app->request->get('aid'); $Course = Course::findOne($aid); return $this->render('article', ['data' => $Course]); }
public function actionTees() { $out = []; if (isset($_POST['depdrop_parents'])) { $parents = $_POST['depdrop_parents']; if ($parents != null) { $course_id = $parents[0]; if ($course = Course::findOne($course_id)) { $selected = null; foreach ($course->getTeesWithHoles() as $tees) { if (!$selected) { $selected = $tees->id; } $out[] = ['id' => $tees->id, 'name' => $tees->name]; } } echo Json::encode(['output' => $out, 'selected' => '']); return; } } echo Json::encode(['output' => '', 'selected' => '']); }