<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class LoanManagerReviewRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return auth()->user()->can('approve loan applications');
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'approved' => 'required|in:0,1',
            'notes' => 'nullable|string|max:1000',
        ];
    }

    /**
     * Get custom messages for validator errors.
     */
    public function messages(): array
    {
        return [
            'approved.required' => 'Please select approved or rejected.',
            'approved.in' => 'Approved value must be 0 or 1.',
            'notes.max' => 'Notes must not exceed 1000 characters.',
        ];
    }
}
