<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ProductPromoCodeDiscountRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, mixed>
     */
    public function rules(): array
    {
        return [
            'promo_code' => [
                'required',
                'string',
                'min:1',
                'max:50',
                'exists:loyalty,promo_code',
            ],
            'products' => [
                'required',
                'array',
            ],
            'products.*' => [
                'required',
                'exists:warehouse,product_code',
            ],
            'client_unique_id' => [
                'required',
                'string',
            ],
        ];
    }
}
