<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

class CouponIndexRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return $this->user()->can('viewAny', \App\Models\Coupon::class);
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'search' => 'nullable',
            'search.value' => 'nullable|string|max:255',
            'type' => 'nullable|in:percentage,fixed',
            'status' => 'nullable|in:active,inactive,expired,not_started,limit_reached',
            'currency_id' => 'nullable|exists:currencies,id',
        ];
    }

    /**
     * Get custom messages for validator errors.
     */
    public function messages(): array
    {
        return [
            'type.in' => 'Geçersiz kupon tipi.',
            'status.in' => 'Geçersiz durum.',
            'currency_id.exists' => 'Geçersiz para birimi.',
        ];
    }
}
