コード例 #1
0
 public function search($params)
 {
     $query = Promotion::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'active' => $this->active, 'student_id' => $this->student_id, 'rank_id' => $this->rank_id, 'date' => $this->date, 'testing_session_id' => $this->testing_session_id]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * Finds the Promotion model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Promotion the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Promotion::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRank()
 {
     $lastPromotion = Promotion::find()->where(['student_id' => $this->id, 'active' => 1])->orderBy(['promotion.date' => SORT_DESC])->one();
     return Rank::findOne($lastPromotion->rank_id);
 }