<?php

namespace App\Http\Requests\Admin\Feedback;

use App\Enums\FeedbackType;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class FeedbackRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->can($this->isMethod('post') ? 'create-feedback' : 'update-feedback');
    }

    public function rules(): array
    {
        return [
            'type' => ['required', 'string', Rule::enum(FeedbackType::class)],
            'subject' => ['required', 'string', 'max:150'],
            'message' => ['required', 'string'],
        ];
    }
}
