Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Teaching::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_subject' => $this->id_subject, 'id_teacher' => $this->id_teacher, 'year' => $this->year]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * Finds the Teaching model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id_subject
  * @param integer $id_teacher
  * @param integer $year
  * @return Teaching the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id_subject, $id_teacher, $year)
 {
     if (($model = Teaching::findOne(['id_subject' => $id_subject, 'id_teacher' => $id_teacher, 'year' => $year])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTeachings()
 {
     return $this->hasMany(Teaching::className(), ['id_subject' => 'id']);
 }