<?php
namespace app\admin\validate\life;

use think\Validate;

class GoodsValidate extends Validate
{
    protected $rule =   [
        'goods_name'  => 'require|max:50',
        'goods_id'    => 'require',
        'goods_img' => 'require',
        'goods_category_id' => 'require',
        'goods_is_new' => 'require',
        'goods_price' => 'require',
        'goods_content' => 'require',
        'goods_postage_id' => 'require',
        'goods_status' => 'require',
    ];

    protected $message  =   [
        'goods_id.require' => '商品ID不能为空',
        'goods_name.require' => '商品名称不能为空',
        'goods_img.require'=> '商品图片不能为空不能为空',
        'goods_category_id.require'   => '商品分类id不能为空',
        'goods_name.max'  => '商品名称不能超过20字',
        'goods_is_new.require' => '商品上新不能为空',
        'goods_price.require' => '商品价格不能为空',
        'goods_content.require' => '商品详情不能为空',
        'goods_postage_id.require' => '关联运费模板不能为空',
        'goods_status.require' => '商品状态不能为空',
    ];

    //场景
    protected $scene = [
        'create'   => ['goods_name','goods_img','goods_category_id','goods_is_new','goods_price','goods_content','goods_postage_id','goods_status'],
        'update'   => ['goods_id','goods_name','goods_img','goods_category_id','goods_is_new','goods_price','goods_content','goods_postage_id','goods_status'],
        'info'     => ['goods_id']
    ];
}
