38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api\V1;
|
|
|
|
use App\Enums\Portal;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class SubscribeNewsletterRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()?->tokenCan('newsletter:subscribe') === true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'portal' => ['required', Rule::in([
|
|
Portal::Presseecho->value,
|
|
Portal::Businessportal24->value,
|
|
])],
|
|
'email' => ['required', 'email', 'max:190'],
|
|
'salutation_key' => ['nullable', 'string', 'max:20'],
|
|
'first_name' => ['nullable', 'string', 'max:80'],
|
|
'last_name' => ['nullable', 'string', 'max:80'],
|
|
];
|
|
}
|
|
}
|