<?php
/**
 * ${CARET}
 * @file:${FILE_NAME}
 * @Created by gnitif
 * @Date: 2023/5/6
 * @Time: 15:16
 */


namespace Modules\CpManage\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Modules\CpManage\Models\Cp\Cps;

class CpRequest extends  FormRequest
{

    /**
     * rules
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'cp_name' => sprintf('required|unique:%s,%s,%s', Cps::class, 'cp_name', $this->get('cp_id')),
            "cp_company" =>  "|required|string|min:1",
            "cp_nick" =>  "|required|string|min:1",
            "share_per" =>  "|required|Integer|min:0|max:100",
            // "share_per_before" =>  "|required|Integer|min:1|max:100",
            // "share_per_after" =>  "|required|Integer|min:1|max:100",
        ];
    }
    /**
     * messages
     *
     * @return string[]
     */
    public function messages(): array
    {
        return [
            'cp_name.required' => 'cp名称必须填写',
            'cp_name.unique' => 'cp名称已存在',
            'cp_company' => '所属公司必填',
            'cp_nick' => 'cp简称必填',
            'address' => '公司地址必填',
            "share_per" => "分成比例不正确",
            "share_per_before" => "分成比例不正确",
            "share_per_after" => "分成比例不正确",
        ];
    }
}
