/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ProgramRecord::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(['id' => $this->id, 'faculty_id' => $this->faculty_id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
public function actionBack($id) { $model = ProgramRecord::findOne($id); $faculty_id = $model->faculty_id; return $this->redirect(['program/index', 'id' => $faculty_id]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($id) { $query = ProgramRecord::find()->where(['faculty_id' => $id]); $dataProvider = new ActiveDataProvider(['query' => $query]); return $dataProvider; }
public function actionPrograms($id) { $first = 1; $count = ProgramRecord::find()->where(['faculty_id' => $id])->count(); $programs = ProgramRecord::find()->where(['faculty_id' => $id])->all(); if ($count > 0) { echo "<option value='" . $first . "'>" . 'select' . "</option>"; foreach ($programs as $program) { echo "<option value='" . $program->id . "'>" . $program->name . "</option>"; } } else { echo "<option>-</option>"; } }
/** * Finds the ProgramRecord model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return ProgramRecord the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = ProgramRecord::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }