<?php
namespace App\Validators;

/**
 * 分佣方案验证器
 */
class CommissionValidator extends BaseValidator {
    //验证规则
    protected $rule =[
        'order_id' =>'required',
        'role' =>'required|in:1,2,3,4,5',
        'user_id' =>'required|exists:users,id',
        'commission_type'=>'required|in:1,2',
        'commission_val'=>'required',
        'send_event'=>'required|in:serve_started,serve_finished',
        'delay'=>'required',
    ];
    //自定义验证信息
    protected $message = [
        'order_id.required' =>'请选择要生成分佣的订单',
        'role.required' =>'请选择分佣角色',
        'role.in' =>'所选角色不存在',
        'user_id.required' =>'请选择伙伴',
        'user_id.exists' =>'所选伙伴不存在',
        'commission_type.required' =>'请选择分佣类型',
        'commission_type.in' =>'分佣类型不存在',
        'commission_val.required' =>'请填写分佣数值',
        'send_event.required' =>'请填写佣金入账事件',
        'send_event.in' =>'佣金入账事件不存在',
        'delay.required' =>'请填写延迟时间,0为不延迟',
    ];

    //自定义场景
    protected $scene = [
        'create' => ['order_id','role','user_id','commission_type','commission_val','send_event','delay'],
        'update' => ['role','user_id','commission_type','commission_val','send_event','delay'],

    ];
}
