Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Cals::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (isset($_GET['CalsSearch']) && !($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'regdate' => $this->regdate, 'updatedate' => $this->updatedate]);
     $date = explode('&', $this->caldate);
     if (count($date) > 1) {
         $date1 = date("Y-m-d", strtotime($date[0]));
         $date2 = date("Y-m-d", strtotime($date[1]));
         $query->andFilterWhere(['and', 'caldate >= "' . $date1 . '"', 'caldate <= "' . $date2 . '"']);
     } else {
         $query->andFilterWhere(['caldate' => $this->caldate]);
     }
     $query->andFilterWhere(['like', 'by', $this->by])->andFilterWhere(['like', 'remark', $this->remark]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * Finds the Cals model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Cals the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Cals::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #3
0
 public function getCal()
 {
     // เชื่อมจาก calitems ไปหา cals
     return $this->hasOne(Cals::className(), ['id' => 'cal_id']);
 }