feat: Phase 3 - public registration pages and Mailwizz config
This commit is contained in:
51
app/Http/Requests/Admin/UpdateMailwizzConfigRequest.php
Normal file
51
app/Http/Requests/Admin/UpdateMailwizzConfigRequest.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use App\Models\PreregistrationPage;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateMailwizzConfigRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
$page = $this->route('page');
|
||||
if (! $page instanceof PreregistrationPage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->user()?->can('update', $page) ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, ValidationRule|string>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
/** @var PreregistrationPage $page */
|
||||
$page = $this->route('page');
|
||||
|
||||
return [
|
||||
'api_key' => [
|
||||
Rule::requiredIf(fn (): bool => $page->mailwizzConfig === null),
|
||||
'nullable',
|
||||
'string',
|
||||
'max:512',
|
||||
],
|
||||
'list_uid' => ['required', 'string', 'max:255'],
|
||||
'list_name' => ['nullable', 'string', 'max:255'],
|
||||
'field_email' => ['required', 'string', 'max:255'],
|
||||
'field_first_name' => ['required', 'string', 'max:255'],
|
||||
'field_last_name' => ['required', 'string', 'max:255'],
|
||||
'field_phone' => $page->phone_enabled
|
||||
? ['required', 'string', 'max:255']
|
||||
: ['nullable', 'string', 'max:255'],
|
||||
'tag_field' => ['required', 'string', 'max:255'],
|
||||
'tag_value' => ['required', 'string', 'max:255'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user