<?php

namespace Modules\Activity\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        $isCreate = $this->isMethod('POST');
        $isUpdate = $this->isMethod('PUT') || $this->isMethod('PATCH');

        if (! $isCreate && ! $isUpdate) {
            return [
                'activity_id' => 'nullable|uuid|exists:activities,id',
                'report_text' => 'nullable|string',
            ];
        }

        return [
            'activity_id' => 'required|uuid|exists:activities,id',
            'report_text' => 'required|string',
        ];
    }

    public function messages(): array
    {
        return [
            'activity_id.required' => 'Aktiviti diperlukan.',
            'activity_id.exists' => 'Aktiviti tidak sah.',
            'report_text.required' => 'Laporan diperlukan.',
        ];
    }
}
