- Added UnsubscribeFromNewsletter action and input/output classes. - Introduced CrmHashcode value object and its cast. - Updated NewsletterController to use the new unsubscribe action. - Enhanced validation in UnsubscribeNewsletterRequest.
33 lines
705 B
PHP
33 lines
705 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Fo;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Ramsey\Uuid\Uuid;
|
|
use Shared\ValueObjects\CrmHashcode;
|
|
|
|
class UnsubscribeNewsletterRequest extends FormRequest
|
|
{
|
|
/** @return array<string,mixed> */
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'hashcode' => ['required', 'uuid'],
|
|
];
|
|
}
|
|
|
|
public function getHashcode(): ?CrmHashcode
|
|
{
|
|
$hashcode = null;
|
|
|
|
$this->string('hashcode')->whenIsUuid(
|
|
function (string $value) use (&$hashcode) {
|
|
$hashcode = new CrmHashcode(Uuid::fromString($value));
|
|
}
|
|
);
|
|
|
|
return $hashcode;
|
|
}
|
|
}
|