Example #1
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['user_id', 'unitcode', 'created_at', 'updated_at', 'created_by', 'updated_by'], 'required'], [['user_id', 'user_power', 'created_at', 'updated_at', 'created_by', 'updated_by'], 'integer'], [['unitcode'], 'string', 'max' => 30], [['user_power'], 'in', 'range' => [self::USER_POWER_VIEW_DEPT, self::USER_POWER_VIEW_ALL, self::USER_POWER_ALLOW]], [['user_id', 'unitcode'], 'unique', 'targetAttribute' => ['user_id', 'unitcode'], 'message' => 'The combination of 用户ID and 单位编码 has already been taken.'], [['unitcode'], 'exist', 'skipOnEmpty' => false, 'targetClass' => Unit::className(), 'targetAttribute' => ['unitcode' => 'unitcode']], [['user_id'], 'exist', 'skipOnEmpty' => false, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']]];
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(User::className(), ['id' => 'user_id']);
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getKasir()
 {
     return $this->hasOne(\mdm\admin\models\User::className(), ['id' => 'created_by']);
 }