<?php

namespace App\Http\Requests\Company\Promoter;

use App\Http\Requests\BaseRequest;
use Illuminate\Validation\Rule;

/**
 * 推广员申请表接口验证
 * @author 唐远望
 * @version 1.0
 * @date 2025-09-04
 * 
 */
class ApplicationForm extends BaseRequest
{
    /**
     * 获取应用于请求的规则
     *
     * @return array
     */
    public function rules()
    {
        // 基础规则定义
        $rules = [
            'name'                 => 'required',
            'id'                   => 'required|integer|gt:0',
            'page'                 => 'integer|min:1',
            'limit'                => 'integer|min:1',
            'status'               => 'required|integer|in:2,3',
            'promoter_remark'      => 'required|string|max:255',
        ];

        return $rules;
    }

    // 场景列表
    protected $scenes = [
        'add'           => [],
        'list'          => ['page','limit'],
        'detail'        => ['id'],
        'audit'         => ['id','status'],
        'set_remark'    => ['id','promoter_remark'],
    ];

    /**
     * 获取已定义验证规则的错误消息
     *
     * @return array
     */
    public function messages()
    {
        return [
            'name.required'                 => '名称必填',
            'id.required'                   => 'ID未知',
            'id.integer'                    => 'ID格式错误',
            'id.gt'                         => 'ID格式错误',
            'status.required'               => '状态未知',
            'status.integer'                => '状态格式错误',
            'status.in'                     => '状态格式错误',
            'page.integer'                  => '页码格式错误',
            'page.min'                      => '页码格式错误',
            'limit.integer'                 => '每页数量格式错误',
            'limit.min'                     => '每页数量格式错误',
            'promoter_remark.required'      => '备注必填',
            'promoter_remark.string'        => '备注格式错误',
            'promoter_remark.max'           => '备注长度超出限制',
            'audit_remark.required'         => '审核备注必填', // 新增错误消息
            'audit_remark.string'           => '审核备注格式错误',
            'audit_remark.max'              => '审核备注长度超出限制',
        ];
    }
}