TimestampBehavior::className(), // 'attributes' => [ // # 创建之前 // ActiveRecord::EVENT_BEFORE_INSERT => ['create_at', 'update_at'], // # 修改之前 // ActiveRecord::EVENT_BEFORE_UPDATE => ['update_at'] // ], // #设置默认值 // 'value' => $_SERVER['REQUEST_TIME'] // ] // ]; // } public function rules() { return [ [['tel','name'],'required','message'=>'{attribute}不能为空'], ['del','in','range'=>[1,2]], ['city','number'], ]; } public function attributeLabels() { return [ 'tel'=>'电话集合', 'name'=>'方案名称', ]; } public function getList($input='') { $query = self::find(); $query->andWhere(['del'=>$this->setDel]); if(!empty($input['city'])){ if(is_numeric($input['city'])){ $query->andWhere(['city'=>$input['city']]); } if(is_string($input['city'])){ $city = explode(',',$input['city']); $query->andWhere(['city'=>$city]); } } $query->orderBy(['create_at'=>SORT_DESC]); $query->asArray(); return $query->all(); } public function CitySchemeTouch() { $query = CategoryCity::find(); } /* * 调用里面的验证,错误返回数组,正确返回对象 * */ public function Authenticator($input) { $this->load($input,''); if(!$this->validate()) return $this->errors; return $this; } public function FindById($id) { return self::findOne($id); } }