ldc-legaulois/app/Http/Requests/Bo/SendTestMailRequest.php

44 lines
988 B
PHP
Raw Permalink Normal View History

<?php
namespace App\Http\Requests\Bo;
use App\Enums\MailToTest;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Validation\Rule;
class SendTestMailRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return auth('backend')->check();
}
public function getMailToTest(): MailToTest
{
return $this->enum('template', MailToTest::class);
}
public function getToAddress(string $fullname): Address
{
return new Address(
$this->string('to')->value(),
$fullname
);
}
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'template' => ['required', Rule::enum(MailToTest::class)],
2026-09-25 16:25:31 +02:00
'to' => ['required', 'email:strict,rfc,spoof'],
];
}
}