40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Admin;
|
|
|
|
use App\Models\PreregistrationPage;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StorePreregistrationPageRequest extends FormRequest
|
|
{
|
|
use ValidatesPreregistrationPageInput;
|
|
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()?->can('create', PreregistrationPage::class) ?? false;
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$this->preparePreregistrationPageSettings();
|
|
$opacity = $this->input('background_overlay_opacity');
|
|
if ($opacity === null || $opacity === '') {
|
|
$this->merge(['background_overlay_opacity' => 50]);
|
|
}
|
|
if ($this->input('background_overlay_color') === null || $this->input('background_overlay_color') === '') {
|
|
$this->merge(['background_overlay_color' => '#000000']);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return array<string, array<int, ValidationRule|string>>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return $this->preregistrationPageSettingsRules();
|
|
}
|
|
}
|