1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace app\admin\validate;
- use app\model\GoodModel;
- use think\facade\Db;
- use think\Validate;
- //商品模块验证器
- class GoodValidate extends Validate
- {
- //验证规则
- protected $rule = [
- 'good_cover_img|商品封面图' => 'require|max:255',
- 'good_name|商品名称' => 'require|max:255',
- 'moq|销售起订量' => 'require|number|min:1|max:999999999',
- 'step|销售步长' => 'require|number|min:1|max:999999999',
- 'good_banner_img|商品轮播图' => 'require|array|min:1|max:100',
- 'good_img|商品详情图' => 'require|array|min:1|max:100',
- 'good_param|商品参数' => 'require|array|min:1|max:100',
- 'unit_id|单位id' => 'require|number|gt:0',
- 'good_remark|商品备注' => 'require|max:255',
- 'type|商品类型' => 'require|number|in:1,2',
- 'price|售价' => 'requireIf:type,2|float|max:99999999.99',
- 'id|主键' => 'require|number|gt:0',
- ];
- //创建商品
- public function sceneAdd()
- {
- return $this
- ->only([
- 'good_cover_img',
- 'good_name',
- 'moq',
- 'step',
- 'good_banner_img',
- 'good_img',
- 'good_param',
- 'unit_id',
- 'good_remark',
- 'type',
- 'price'
- ]);
- }
- //修改商品信息
- public function sceneEdit()
- {
- return $this->remove('type', true);
- }
- //获取商品详情
- public function sceneRead()
- {
- return $this->only(['id']);
- }
- }
|