|
@ -54,9 +54,25 @@ class Category extends \yii\db\ActiveRecord |
|
|
[['pid', 'goods_count', 'sort_order', 'is_show', 'is_delete', 'icon'], 'integer'], |
|
|
[['pid', 'goods_count', 'sort_order', 'is_show', 'is_delete', 'icon'], 'integer'], |
|
|
[['name'], 'string', 'max' => 60], |
|
|
[['name'], 'string', 'max' => 60], |
|
|
[['iconImageId'], 'string'], |
|
|
[['iconImageId'], 'string'], |
|
|
|
|
|
[['sort_order'], 'checkNegative'], |
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @param $attribute |
|
|
|
|
|
* @param $params |
|
|
|
|
|
* 验证是否为负数 |
|
|
|
|
|
*/ |
|
|
|
|
|
public function checkNegative($attribute, $params) |
|
|
|
|
|
{ |
|
|
|
|
|
if ($this->$attribute < 0) { |
|
|
|
|
|
$this->addError($attribute, "不得为负数"); |
|
|
|
|
|
} |
|
|
|
|
|
if ($this->$attribute > 65535) { |
|
|
|
|
|
$this->addError($attribute, "不得大于65535"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* {@inheritdoc} |
|
|
* {@inheritdoc} |
|
|
*/ |
|
|
*/ |
|
|