1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/4/8
- * Time: 上午8:46
- */
- namespace common\models;
- //use yii\db\ActiveRecord;
- //use yii\behaviors\TimestampBehavior;
- class CategoryTel extends Common
- {
- // public $setDel = 1;
- // public function behaviors()
- // {
- // return [
- // [
- // 'class' => 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);
- }
- }
|