<?php

namespace Modules\SystemTool\Http\Requests;

use Illuminate\Validation\Rules\Exists;
use Modules\Common\Http\Requests\BaseFormRequest;
use Modules\SystemTool\Models\SysFileModel;

class SysGridNavFormRequest extends BaseFormRequest
{
    protected $stopOnFirstFailure = true;

    public function rules(): array
    {
        return [
            'title' => 'required|string|max:100',
            'image_id' => ['required', 'integer', new Exists(SysFileModel::class, 'id')],
            'link' => 'nullable|string|max:500',
            'status' => 'nullable|integer|in:0,1',
            'sort' => 'nullable|integer',
        ];
    }

    public function messages(): array
    {
        return [
            'title.required' => '导航标题是必填的',
            'title.max' => '导航标题不能超过 :max 个字符',
            'image_id.required' => '导航图标是必填的',
            'link.max' => '跳转链接不能超过 :max 个字符',
            'status.in' => '状态值只能是 0（启用）或 1（禁用）',
            'sort.integer' => '排序必须是整数',
        ];
    }
}
