ldc-legaulois/app/Http/Requests/Bo/SendTestMailRequest.php
2026-09-23 15:11:48 +02:00

46 lines
1,004 B
PHP

<?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.
*
* @return boolean
*/
public function authorize(): bool
{
return auth('backend')->check();
}
public function getMailToTest(): MailToTest
{
return $this->enum('template', MailToTest::class);
}
public function getToAddress(): Address
{
return new Address(
$this->string('to')->value()
);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
'template' => ['required', Rule::enum(MailToTest::class)],
'to' => ['required', 'email:strict,rfc,spoof']
];
}
}