<?php namespace App\Http\Requests\Api\WeiZan;

use App\Http\Requests\BaseRequest;
use App\Rules\JsonArray;

/**
 * 订单验证器
 * 
 */
class Orders extends BaseRequest
{
    /**
     * 获取应用于请求的规则
     *
     * @return array
     */
    public function rules()
    {
        // 编辑时排除ID
        // 返回结果
        return      [
            // 有时候我们希望某个字段在第一次验证失败后就停止运行验证规则，只需要将 bail 添加到规则中：
            // 验证字段，验证规则，提示信息
            'id'            => 'required|integer|gt:0',
            'user_id'       => 'required|integer|gt:0',
            'user_name'     => 'required',
            'user_phone'    => 'required',
            'pay_amount'    => 'required|numeric',
            'order_amount'  => 'required|numeric',
            'status'        => 'required',
            'contact_name'  => 'required',
            'contact_phone' => 'required',
            'address'       => 'required',
            'create_time'   => 'required',
            'modify_time'   => 'required',
            'order_items'   => ['required','json',new JsonArray(['id'=>'required','product_name'=>'required','product_price'=>'required|numeric','product_orgprice'=>'required|numeric','product_image'=>'required','sku_value'=>'required','number'=>'required|numeric','sub_total'=>'required|numeric','modify_time'=>'required'])],
        ];
    }

    // 场景列表
    protected   $scenes         = [
	];

    /**
     * 获取已定义验证规则的错误消息
     *
     * @return array
     */
    public function messages()
    {
        return [

        ];
    }

}
