<?php
/**
 * @copyright   Copyright (c) 2017 https://www.sapixx.com All rights reserved.
 * @license     Licensed (http://www.apache.org/licenses/LICENSE-2.0).
 * @author      pillar<ltmn@qq.com>
 * 商品管理
 */
namespace app\ais\validate;
use think\Validate;

class Shop extends Validate{

    protected $rule = [
        'name'              => 'require',
        'title'             => 'require',
        'category_id'       => 'require|number',
        'img'               => 'require',
        'imgs'              => 'require|array',
        'sell_price'        => 'require|float',
        'market_price'      => 'require|float',
        'cost_price'        => 'require|float',
        'warehouse_num'     => 'require|number',
        'warehouse_sellnum' => 'require|number',
        'weight'            => 'require|number',
        'content'           => 'require',
        'notice'            => 'require',
        'group_title'       => 'require',
        'group_note'        => 'require',
    ];

    protected $message = [
        'category_id'           => '商品分类必须输入',
        'title'                 => '商品推荐标题必须输入',
        'name'                  => '商品名称必须输入',
        'img'                   => '没有设置默认图片',
        'imgs'                  => '没有设置商品图片',
        'sell_price'            => '销售价不能为空',
        'sell_price.number'     => '销售价只能填写数字',
        'market_price.require'  => '市场价不能为空入',
        'market_price.number'   => '市场价只能填写数字',
        'cost_price.require'    => '成本价不能为空',
        'cost_price.number'     => '成本价只能填写数字',
        'warehouse_num.require' => '库存不能为空',
        'warehouse_num.gt'      => '库存必须大于0',
        'warehouse_sellnum'     => '虚拟已售必须填写',
        'content'               => '商品描述必须填写',
        'group_title'           => '群名称必须填写',
        'group_note'            => '群简介必须填写',
        'notice'                => '购买须知必须填写',
    ];

    protected $scene = [
        'save'  => ['category_id','name','title','img','imgs','sell_price','market_price','cost_price','content','notice','warehouse_num','warehouse_sellnum'],
    ];
}