<?php

namespace Mamad\Product\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Mamad\Product\Rules\HourAndMinuteValidation;

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

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules= [
            "name"=>"required|min:2|unique:coupon,id,".request()->route("coupon")->id,
            "price_offering"=>"numeric|min:0",
            "price_type"=>[Rule::in(["percent","cash"])],
            "time"=>"date",
            "hour"=>["required",new HourAndMinuteValidation()],
            'number' => 'nullable|numeric|min:0',
        ];

        return $rules;
    }
}
