<?php

namespace App\Http\Requests\Member;

use Illuminate\Foundation\Http\FormRequest;

// ══════════════════════════════════════════════════════════════════
//  InPractice — StoreForumReplyRequest
//  Location: app/Http/Requests/Member/StoreForumReplyRequest.php
//
//  Validates creating a reply to a forum post.
//  parent_reply_id optional — allows replying to a reply (one level).
//  Body minimum 10 chars — replies can be shorter than posts.
// ══════════════════════════════════════════════════════════════════

class StoreForumReplyRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'body'               => ['required', 'string', 'min:10'],
            'posted_as_nickname' => ['boolean'],
            'parent_reply_id'    => ['nullable', 'integer', 'exists:forum_replies,id'],
        ];
    }

    public function messages(): array
    {
        return [
            'body.required'          => __('forum.validation_reply_required'),
            'body.min'               => __('forum.validation_reply_min'),
            'parent_reply_id.exists' => __('forum.validation_parent_invalid'),
        ];
    }
}
