<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

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

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'search' => 'nullable|string|max:255',
            'client_id' => 'nullable|integer|exists:clients,id',
            'currency_id' => 'nullable|integer|exists:currencies,id',
            'status' => 'nullable|string|in:positive,negative,zero',
        ];
    }

    /**
     * Get custom messages for validator errors.
     */
    public function messages(): array
    {
        return [
            'client_id.exists' => 'Seçilen müşteri bulunamadı.',
            'currency_id.exists' => 'Seçilen para birimi bulunamadı.',
            'status.in' => 'Geçersiz bakiye durumu.',
        ];
    }
}
