12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/4/4
- * Time: 上午11:34
- */
- namespace common\models;
- use yii\db\ActiveRecord;
- use yii\behaviors\TimestampBehavior;
- class CategoryTel extends ActiveRecord
- {
- 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]],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'tel'=>'电话集合',
- 'name'=>'方案名称',
- ];
- }
- public function getList()
- {
- $query = self::find();
- $query->andWhere(['del'=>$this->setDel]);
- $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);
- }
- }
|