<?php

namespace app\admin\validate\healthy;

use support\Validate;

class ProductValidate extends Validate
{
    protected $rule = [
        'product_id' => 'require|integer',
        'product_category_id' => 'require|integer',
        'product_shop_id' => 'require|integer',
        'product_name|产品名称' => 'require',
        'product_price|价格' => 'require|float',
        'product_freight_fee|运费' => 'require|float',
        'product_postage_id|运费模板' => 'require|integer',
        'product_packing_fee|打包费' => 'require|float',
        'product_weight|重量' => 'require|float',
        'product_image|图片' => 'regex:/^[0-9a-zA-Z\.\/]+$/',
        'product_image_slide|轮播图' => 'regex:/^[0-9a-zA-Z\.\/\,]+$/',
        'product_limit|限制内容' => 'max:150',
        'product_notice|产品须知' => 'max:150',
        'product_guarantee|产品保障' => 'max:150',
        'product_type|产品类型' => 'in:0,1',
        'product_status|状态' => 'in:0,1',
        'product_audit|审核' => 'in:0,1,2',
        'product_sort|排序' => 'require|integer',
        'product_reject_reason' => 'max:255'
    ];

    protected $message = [];

    protected $scene = [
        'add' => ['product_category_id', 'product_shop_id', 'product_name', 'product_price', 'product_freight_fee', 'product_postage_id',
            'product_packing_fee', 'product_weight', 'product_image', 'product_image_slide', 'product_limit', 'product_notice',
            'product_guarantee', 'product_type', 'product_status', 'product_audit', 'product_sort'],

        'update' => ['product_id', 'product_category_id', 'product_shop_id', 'product_name', 'product_price', 'product_freight_fee',
            'product_postage_id', 'product_packing_fee', 'product_weight', 'product_image', 'product_image_slide', 'product_limit',
            'product_notice', 'product_guarantee', 'product_type', 'product_status', 'product_audit', 'product_sort','product_reject_reason'],
    ];
}
