60 lines
1.5 KiB
PHP
60 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\validate\vip;
|
|
|
|
use app\common\validate\BaseValidate;
|
|
use app\common\model\vip\VipLevel;
|
|
|
|
class VipLevelValidate extends BaseValidate
|
|
{
|
|
protected $rule = [
|
|
'id' => 'require|checkLevel',
|
|
'name' => 'require|length:1,50',
|
|
'level' => 'require|integer|gt:0',
|
|
'price' => 'require|float|gt:0',
|
|
'duration' => 'require|integer|gt:0',
|
|
];
|
|
|
|
protected $message = [
|
|
'id.require' => '等级id不能为空',
|
|
'name.require' => '等级名称不能为空',
|
|
'name.length' => '等级名称长度须在1-50位字符',
|
|
'level.require' => '等级序号不能为空',
|
|
'level.integer' => '等级序号须为整数',
|
|
'level.gt' => '等级序号须大于0',
|
|
'price.require' => '价格不能为空',
|
|
'price.gt' => '价格须大于0',
|
|
'duration.require' => '有效天数不能为空',
|
|
'duration.integer' => '有效天数须为整数',
|
|
'duration.gt' => '有效天数须大于0',
|
|
];
|
|
|
|
public function sceneAdd()
|
|
{
|
|
return $this->remove('id', 'require|checkLevel');
|
|
}
|
|
|
|
public function sceneEdit()
|
|
{
|
|
}
|
|
|
|
public function sceneDetail()
|
|
{
|
|
return $this->only(['id']);
|
|
}
|
|
|
|
public function sceneDelete()
|
|
{
|
|
return $this->only(['id']);
|
|
}
|
|
|
|
public function checkLevel($value)
|
|
{
|
|
$level = VipLevel::findOrEmpty($value);
|
|
if ($level->isEmpty()) {
|
|
return 'VIP等级不存在';
|
|
}
|
|
return true;
|
|
}
|
|
}
|