Beispiel #1
0
 public static function getProgramByAttribute($args)
 {
     $programs = Program::find()->where($args)->all();
     $retVal = array();
     foreach ($programs as $program) {
         $itemArr = array();
         $itemArr['subject'] = Subjects::findOne(['id' => $program->subject])->name;
         $itemArr['semester'] = $program->semester;
         $itemArr['subject_id'] = $program->subject;
         $retVal[] = $itemArr;
     }
     return $retVal;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Program::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(['created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
 public function actionList()
 {
     $data = Program::getAllProgram();
     return $this->render('list', $data);
 }
Beispiel #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProgram()
 {
     return $this->hasOne(Program::className(), ['id' => 'program_id']);
 }
 /**
  * Finds the Program model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Program the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Program::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #6
0
 public static function suggest($department_id, $semester)
 {
     $args = ['department_id' => $department_id, 'semester' => $semester];
     $data = Program::getProgramByAttribute($args);
     return $data;
 }
 public function limitResults()
 {
     $program = Program::all();
     return Response::json($program);
 }