<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreEmailMessageRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->can('email.create');
    }

    public function rules(): array
    {
        return [
            'recipient' => ['required', 'email', 'max:255'],
            'subject' => ['required', 'string', 'max:255'],
            'body' => ['required', 'string'],
            'template_id' => ['nullable', 'integer', 'exists:email_templates,id'],
        ];
    }
}
