|
@ -45,13 +45,26 @@ class ExpressTemplate extends \yii\db\ActiveRecord |
|
|
public function rules() |
|
|
public function rules() |
|
|
{ |
|
|
{ |
|
|
return [ |
|
|
return [ |
|
|
[['name', 'calculation'], 'required'], |
|
|
|
|
|
[['province', 'city', 'area'], 'string'], |
|
|
|
|
|
[['calculation', 'basic_price', 'basic_amount', 'extra_price', 'extra_amount'], 'integer'], |
|
|
|
|
|
|
|
|
[['name', 'calculation', 'basic_price', 'basic_amount'], 'required'], |
|
|
|
|
|
[['province', 'city', 'area', 'basic_price', 'extra_price'], 'string'], |
|
|
|
|
|
[['calculation', 'basic_amount', 'extra_amount'], 'integer'], |
|
|
[['name'], 'string', 'max' => 255], |
|
|
[['name'], 'string', 'max' => 255], |
|
|
|
|
|
[['basic_amount', 'basic_price', 'extra_price', 'extra_amount'], 'checkNegative'], |
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @param $attribute |
|
|
|
|
|
* @param $params |
|
|
|
|
|
* 验证是否为负数 |
|
|
|
|
|
*/ |
|
|
|
|
|
public function checkNegative($attribute, $params) |
|
|
|
|
|
{ |
|
|
|
|
|
if ($this->$attribute < 0) { |
|
|
|
|
|
$this->addError($attribute, "不得为负数"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* {@inheritdoc} |
|
|
* {@inheritdoc} |
|
|
*/ |
|
|
*/ |
|
|