caipan_shop_admin/app/validate/Goods.php

44 lines
1.7 KiB
PHP
Executable File

<?php
namespace app\validate;
use think\Validate;
class Goods extends Validate
{
protected $rule = [
'page|页数' => 'number',
'size|每页数量' => 'number',
'category|商品分类' => 'number',
'title|标题' => 'require|min:4|max:255',
'name|名称' => 'require',
'cover|缩略图' => 'require',
'type|商品类型' => 'in:goods,auction,special',
'content|内容' => 'require',
'price|价格' => 'float',
'minimum_amount|最低加价金额' => 'float',
'service_charge|服务费' => 'float',
'id|ID' => 'require|number',
'sort|排序方式' => 'require|in:up,down',
'num|移动位数' => 'require|number|min:1',
'pid|上级分类' => 'require|number',
'begin_at|开售时间' => 'require|date',
'end_at|结束时间' => 'require|date',
];
protected $message = [
'type.in' => '商品类型必需是[商城商品][竞拍商品][专场商品]三者之一'
];
protected $scene = [
'base' => ['page', 'size'],//普通模式
'manager_add' => ['type', 'title', 'cover', 'content', 'price', 'service_charge', 'minimum_amount'],//后台添加
'manager_edit' => ['type', 'title', 'cover', 'content', 'price', 'service_charge', 'minimum_amount'],//后台修改
'sort' => ['id', 'sort', 'num'],//排序
'manager_category' => ['pid', 'name'],//分类添加与编辑
'manager_special' => ['name', 'begin_at', 'end_at'],//专场添加与编辑
];
}