diff --git a/app/Enums/StaticPageType.php b/app/Enums/StaticPageType.php index 519fa1d..cb7a035 100644 --- a/app/Enums/StaticPageType.php +++ b/app/Enums/StaticPageType.php @@ -52,4 +52,25 @@ enum StaticPageType: int self::we_listen, ]; } + + /** + * Does the static page need to fill its 'content' column ? + * + * @return boolean + */ + public function containsContent(): bool + { + return match ($this) { + self::contact, + self::legals, + self::confidentiality => true, + self::home, + self::unveil, + self::we_hire, + self::we_commit, + self::we_move, + self::we_produce, + self::we_listen => false, + }; + } } diff --git a/resources/views/bo/pages/static_pages/form.blade.php b/resources/views/bo/pages/static_pages/form.blade.php index 4b3d529..ad37e9e 100644 --- a/resources/views/bo/pages/static_pages/form.blade.php +++ b/resources/views/bo/pages/static_pages/form.blade.php @@ -12,7 +12,9 @@ 'model' => $staticPageModel ?? null, 'required' => false, 'disabled' => true, - 'associatedModels' => \App\Enums\StaticPageType::toArray(), + 'associatedModels' => Arr::where( + \App\Enums\StaticPageType::toArray(), + fn(object $type) => $type->value === $staticPageModel->type->value), 'helper' => '', ]) @@ -125,30 +127,32 @@ -
- {{-- CONTENT --}} -
-
- {{ Str::ucfirst(__('validation.attributes.content')) }} -
-
- @include('bo.partials.inputs.text-html', [ - 'id' => 'articleContent', - 'label' => __(':field :inter:model', [ - 'field' => Str::ucfirst(__('validation.attributes.content')), - 'inter' => __('validation.custom.of_the.female'), - 'model' => trans_choice('models.classes.static_page', 1), - ]), - 'name' => 'content', - 'model' => $staticPageModel ?? null, - 'required' => true, - 'helper' => __('crud.minicrud.text_warning'), - ]) +@if ($staticPageModel->type->containsContent()) +
+ {{-- CONTENT --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.content')) }} +
+
+ @include('bo.partials.inputs.text-html', [ + 'id' => 'articleContent', + 'label' => __(':field :inter:model', [ + 'field' => Str::ucfirst(__('validation.attributes.content')), + 'inter' => __('validation.custom.of_the.female'), + 'model' => trans_choice('models.classes.static_page', 1), + ]), + 'name' => 'content', + 'model' => $staticPageModel ?? null, + 'required' => true, + 'helper' => __('crud.minicrud.text_warning'), + ]) +
-
-
+ +
- +@endif
diff --git a/routes/web-bo.php b/routes/web-bo.php index 66a2670..8f5d961 100644 --- a/routes/web-bo.php +++ b/routes/web-bo.php @@ -54,7 +54,9 @@ Route::prefix('bo') 'edit' => 'static_pages.edit', 'update' => 'static_pages.update', ])->parameters(['pages' => 'static_page']) - ->only(['index', 'edit', 'update']); + ->only(['index', 'edit', 'update']) + ->withoutMiddleware('htmlsanitize') + ->middleware('htmlsanitize:content'); // * NEWS. Route::resource('news', NewsController::class)->except('show')