Adds background_fixed column, admin checkbox, fixed-position layers on the public layout, Dutch strings, and store tests. Made-with: Cursor
96 lines
3.6 KiB
PHP
96 lines
3.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Admin;
|
|
|
|
use App\Models\PageBlock;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
trait ValidatesPreregistrationPageInput
|
|
{
|
|
/**
|
|
* @return array<string, array<int, ValidationRule|string>>
|
|
*/
|
|
protected function preregistrationPageSettingsRules(): array
|
|
{
|
|
return [
|
|
'title' => ['required', 'string', 'max:255'],
|
|
'thank_you_message' => ['nullable', 'string'],
|
|
'expired_message' => ['nullable', 'string'],
|
|
'ticketshop_url' => ['nullable', 'string', 'url:http,https', 'max:255'],
|
|
'post_submit_redirect_url' => ['nullable', 'string', 'url:http,https', 'max:500'],
|
|
'background_overlay_color' => ['nullable', 'string', 'regex:/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/'],
|
|
'background_overlay_opacity' => ['nullable', 'integer', 'min:0', 'max:100'],
|
|
'background_fixed' => ['sometimes', 'boolean'],
|
|
'page_background' => ['nullable', 'file', 'image', 'mimes:jpeg,png,jpg,webp', 'max:5120'],
|
|
'remove_page_background' => ['sometimes', 'boolean'],
|
|
'start_date' => ['required', 'date'],
|
|
'end_date' => ['required', 'date', 'after:start_date'],
|
|
'is_active' => ['sometimes', 'boolean'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, array<int, ValidationRule|string>>
|
|
*/
|
|
protected function preregistrationPageBlocksRules(): array
|
|
{
|
|
return [
|
|
'blocks' => ['required', 'array', 'min:1'],
|
|
'blocks.*.type' => ['required', 'string', Rule::in(PageBlock::TYPES)],
|
|
'blocks.*.sort_order' => ['required', 'integer', 'min:0', 'max:9999'],
|
|
'blocks.*.is_visible' => ['sometimes', 'boolean'],
|
|
'blocks.*.content' => ['required', 'array'],
|
|
'blocks.*.remove_block_image' => ['sometimes', 'boolean'],
|
|
'blocks.*.block_image' => ['nullable', 'file', 'mimes:jpeg,png,jpg,webp,svg', 'max:5120'],
|
|
];
|
|
}
|
|
|
|
protected function preparePreregistrationPageSettings(): void
|
|
{
|
|
$ticketshop = $this->input('ticketshop_url');
|
|
$ticketshopNormalized = null;
|
|
if (is_string($ticketshop) && trim($ticketshop) !== '') {
|
|
$ticketshopNormalized = trim($ticketshop);
|
|
}
|
|
|
|
$redirect = $this->input('post_submit_redirect_url');
|
|
$redirectNormalized = null;
|
|
if (is_string($redirect) && trim($redirect) !== '') {
|
|
$redirectNormalized = trim($redirect);
|
|
}
|
|
|
|
$opacity = $this->input('background_overlay_opacity');
|
|
$opacityInt = null;
|
|
if ($opacity !== null && $opacity !== '') {
|
|
$opacityInt = max(0, min(100, (int) $opacity));
|
|
}
|
|
|
|
$this->merge([
|
|
'is_active' => $this->boolean('is_active'),
|
|
'background_fixed' => $this->boolean('background_fixed'),
|
|
'remove_page_background' => $this->boolean('remove_page_background'),
|
|
'ticketshop_url' => $ticketshopNormalized,
|
|
'post_submit_redirect_url' => $redirectNormalized,
|
|
'background_overlay_opacity' => $opacityInt,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @deprecated use preregistrationPageSettingsRules
|
|
*
|
|
* @return array<string, array<int, ValidationRule|string>>
|
|
*/
|
|
protected function preregistrationPageRules(): array
|
|
{
|
|
return array_merge($this->preregistrationPageSettingsRules(), $this->preregistrationPageBlocksRules());
|
|
}
|
|
|
|
protected function preparePreregistrationPageFields(): void
|
|
{
|
|
$this->preparePreregistrationPageSettings();
|
|
}
|
|
}
|