Added Feedback section.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Site\Feedback;
|
||||
|
||||
use App\Contracts\FormRequestDto;
|
||||
use App\Dto\HttpUserData;
|
||||
use App\Dto\Service\Site\Feedback\Send;
|
||||
use App\Services\WebsiteTranslations;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class SendRequest extends FormRequest implements FormRequestDto
|
||||
{
|
||||
public function attributes(): array
|
||||
{
|
||||
$attributes = [];
|
||||
|
||||
$websiteTranslations = $this->request->get('websiteTranslations', null);
|
||||
if ($websiteTranslations) {
|
||||
/** @var WebsiteTranslations $websiteTranslations */
|
||||
$attributes = [
|
||||
'name' => $websiteTranslations->translate('site.attributes.name'),
|
||||
'email' => $websiteTranslations->translate('site.attributes.email'),
|
||||
'message' => $websiteTranslations->translate('site.attributes.message'),
|
||||
];
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['nullable', 'string', 'max:255'],
|
||||
'email' => ['nullable', 'string', 'max:255', 'email'],
|
||||
'message' => ['required', 'string', 'max:5000'],
|
||||
'captcha-verified' => ['captcha'],
|
||||
];
|
||||
}
|
||||
|
||||
public function getDto(): Send
|
||||
{
|
||||
$httpUserData = new HttpUserData(
|
||||
clientIp: $this->getClientIp(),
|
||||
userAgent: $this->userAgent(),
|
||||
);
|
||||
|
||||
return new Send(
|
||||
message: $this->input('message'),
|
||||
httpUserData: $httpUserData,
|
||||
name: $this->input('name', null),
|
||||
email: $this->input('email', null),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user