/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Courses::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['credit_hours' => $this->credit_hours, 'level' => $this->level, 'dept_ID' => $this->dept_ID]); $query->andFilterWhere(['like', 'course_ID', $this->course_ID])->andFilterWhere(['like', 'course_name', $this->course_name]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getCourses() { return $this->hasMany(Courses::className(), ['updated_by' => 'user_id']); }
/** * @return \yii\db\ActiveQuery */ public function getCourses() { return $this->hasMany(Courses::className(), ['dept_ID' => 'ID']); }
public function getCourses() { return $this->hasMany(Courses::className(), ['id' => 'course_id'])->viaTable(StudentsCourses::tableName(), ['student_id' => 'id'])->all(); }
/** * @return \yii\db\ActiveQuery */ public function getCourse() { return $this->hasOne(Courses::className(), ['id' => 'course_id']); }
/* @var $model app\models\Content */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="content-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'text')->widget(CKEditor::className(), ['editorOptions' => ['preset' => 'full', 'inline' => false]]); ?> <?php echo $form->field($model, 'courses_id')->dropDownList(Courses::getAll(), ['prompt' => 'Select Course']); ?> <div class="form-group"> <div> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> </div> <?php ActiveForm::end(); ?> </div>
public function getAll() { return ArrayHelper::map(Courses::find()->all(), 'id', 'courses'); }
/** * Finds the Courses model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Courses the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Courses::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionVideo() { $courses = Courses::find()->orderBy(['id' => SORT_DESC])->all(); return $this->render('video', ['courses' => $courses]); }