12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/3/25
- * Time: 下午8:42
- */
- namespace common\models;
- //use yii\db\ActiveRecord;
- //use yii\behaviors\TimestampBehavior;
- class CategoryWatermark 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 getWatermarkInfo()
- {
- $query = self::find();
- $query->andWhere(['del'=>$this->setDel]);
- $query->andWhere(['status'=>1]);
- return $query->one();
- }
- public function rules()
- {
- return [
- [['width','height','position'],'required','message'=>'{attribute}不能为空'],
- ['position','in','range'=>[1,2,3,4,5,6,7,8,9]],
- [['width','height'],'number','max'=>300],
- ['spacing','number','max'=>50],
- ['status','in','range'=>[1,2]],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'width'=>'宽度',
- 'height'=>'高度',
- 'position'=>'水印位置',
- 'spacing'=>'间距',
- ];
- }
- public function FindById($id)
- {
- return self::findOne($id);
- }
- }
|