/** * 获取添加的预定报警号码 */ private function get_config() { if ($this->cptype == 'cq') { //重庆时时彩 $config = \app\models\Reserve::find()->where(['cp_type' => 1])->all(); // $this->cp_name = '重庆'; $this->cp_name = '庆'; } if ($this->cptype == 'tj') { ///天津时时彩 $config = \app\models\Reserve::find()->where(['cp_type' => 2])->all(); // $this->cp_name = '天津'; $this->cp_name = '津'; } if ($this->cptype == 'xj') { //新疆时时彩 $config = \app\models\Reserve::find()->where(['cp_type' => 3])->all(); // $this->cp_name = '新疆'; $this->cp_name = '疆'; } if (!$config) { echo '系统还未添加 -[' . $this->cp_name . '彩票] 预定报警号码,请先添加' . "\r\n"; } $this->config = $config; }
/** * Finds the User model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return User the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Reserve::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Reserve::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['reserveStudent.person_name'] = ['asc' => ['person.person_name' => SORT_ASC], 'desc' => ['person.person_name' => SORT_DESC]]; $dataProvider->sort->attributes['reserveCoach.person_name'] = ['asc' => ['person.person_name' => SORT_ASC], 'desc' => ['person.person_name' => SORT_DESC]]; $dataProvider->sort->attributes['reserveSpot.spot_name'] = ['asc' => ['spot.spot_name' => SORT_ASC], 'desc' => ['spot.spot_name' => SORT_DESC]]; $query->joinWith(['reserveStudent', 'reserveSpot']); $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(['reserve_id' => $this->reserve_id, 'reserve_student_id' => $this->reserve_student_id, 'reserve_coach_id' => $this->reserve_coach_id, 'reserve_spot_id' => $this->reserve_spot_id, 'reserve_date' => $this->reserve_date, 'reserve_start_time' => $this->reserve_start_time]); $query->andFilterWhere(['like', 'person.person_name', $this->getAttribute('reserveStudent.person_name')])->andFilterWhere(['like', 'person.person_name', $this->getAttribute('reserveCoach.person_name')])->andFilterWhere(['like', 'spot.spot_name', $this->getAttribute('spot.spot_name')]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getReserves0() { return $this->hasMany(Reserve::className(), ['reserve_student_id' => 'person_id']); }
/** * @return \yii\db\ActiveQuery */ public function getReserves() { return $this->hasMany(Reserve::className(), ['reserve_spot_id' => 'spot_id']); }