From e365eb5f5edd55c7d348fb5afec36bf8aeebebe9 Mon Sep 17 00:00:00 2001 From: Noah Lancien Date: Mon, 6 Nov 2023 10:43:40 +0100 Subject: [PATCH] Removed show_title form static pages --- .../Bo/StaticPages/StoreStaticPageRequest.php | 2 -- app/Models/Site/StaticPage.php | 10 +++--- ...ove_show_title_from_static_pages_table.php | 33 +++++++++++++++++++ .../views/pages/static_pages/form.blade.php | 31 +++++++---------- 4 files changed, 49 insertions(+), 27 deletions(-) create mode 100644 database/migrations/2023_11_06_102900_remove_show_title_from_static_pages_table.php diff --git a/app/Http/Requests/Bo/StaticPages/StoreStaticPageRequest.php b/app/Http/Requests/Bo/StaticPages/StoreStaticPageRequest.php index cdd52a0..ec8021e 100644 --- a/app/Http/Requests/Bo/StaticPages/StoreStaticPageRequest.php +++ b/app/Http/Requests/Bo/StaticPages/StoreStaticPageRequest.php @@ -45,7 +45,6 @@ class StoreStaticPageRequest extends FormRequest $this->mergePicture('banner'); $this->merge([ 'value' => $this->value ? $this->value : '', - 'show_title' => $this->show_title ? true : false, 'show_banner' => $this->show_banner ? true : false ]); } @@ -59,7 +58,6 @@ class StoreStaticPageRequest extends FormRequest { return \array_merge([ 'title' => 'required|string|min:3|max:255', - 'show_title' => 'required|boolean', 'show_banner' => 'required|boolean', 'value' => 'present|string|min:0' ], $this->pictureRules( diff --git a/app/Models/Site/StaticPage.php b/app/Models/Site/StaticPage.php index d844443..1937677 100644 --- a/app/Models/Site/StaticPage.php +++ b/app/Models/Site/StaticPage.php @@ -25,7 +25,6 @@ class StaticPage extends Model protected $casts = [ 'date_start' => 'datetime', 'date_end' => 'datetime', - 'show_title' => 'bool', 'show_banner' => 'bool' ]; @@ -45,7 +44,6 @@ class StaticPage extends Model */ protected $fillable = [ 'title', - 'show_title', 'show_banner', 'value', 'banner' @@ -61,10 +59,10 @@ class StaticPage extends Model // * EVENT CLOSURES. static::creating(function (self $model) { if (!$model->type->equals(StaticPageType::crud())) { - throw new \RuntimeException('Impossible de créer :model de type autre que :type.', [ + throw new \RuntimeException(__('Impossible de créer :model de type autre que :type.', [ 'model' => \trans('models.classes.static_pages'), 'type' => StaticPageType::crud()->label - ]); + ])); } // * ASSERTIONS static::assertTitleIsUnique($model->title); @@ -95,10 +93,10 @@ class StaticPage extends Model }); static::deleting(function (self $model) { if (!$model->type->equals(StaticPageType::crud())) { - throw new \RuntimeException('Impossible de supprimer :model de type autre que :type.', [ + throw new \RuntimeException(__('Impossible de supprimer :model de type autre que :type.', [ 'model' => \trans('models.classes.static_pages'), 'type' => StaticPageType::crud()->label - ]); + ])); } }); static::deleted(function (self $model) { diff --git a/database/migrations/2023_11_06_102900_remove_show_title_from_static_pages_table.php b/database/migrations/2023_11_06_102900_remove_show_title_from_static_pages_table.php new file mode 100644 index 0000000..1d08bca --- /dev/null +++ b/database/migrations/2023_11_06_102900_remove_show_title_from_static_pages_table.php @@ -0,0 +1,33 @@ +dropColumn('show_title'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('static_pages', function (Blueprint $table) { + $table->boolean('show_title')->after('title') + ->comment('Afficher le titre ?'); + }); + } +} diff --git a/resources/views/pages/static_pages/form.blade.php b/resources/views/pages/static_pages/form.blade.php index fb3d9f2..2f1bc53 100644 --- a/resources/views/pages/static_pages/form.blade.php +++ b/resources/views/pages/static_pages/form.blade.php @@ -1,6 +1,6 @@ {{-- TITLE --}}
-
+
@include('back::partials.inputs.varchar', [ 'id' => 'staticPageTitle', 'hasWordCounter' => true, @@ -9,26 +9,16 @@ 'model' => $static_pageModel ?? null, 'required' => false, 'placeholder' => __('Un titre beau et explicite'), - 'helper' => __('Doit décrire précisément la page') - ]) -
-
- @include('back::partials.inputs.tinyint-boolean', [ - 'id' => 'staticPageShowTitle', - 'label' => __('Afficher le titre'), - 'name' => 'show_title', - 'model' => $static_pageModel ?? null, - 'required' => false, - 'helper' => __('Afficher en front le titre de la page ou non') + 'helper' => __('Doit décrire précisément la page'), ])
{{-- BANNER --}} -
+
- +
@@ -39,7 +29,7 @@ 'name' => 'show_banner', 'model' => $static_pageModel ?? null, 'required' => false, - 'helper' => __('Afficher en front la banniere de la page ou non') + 'helper' => __('Afficher en front la banniere de la page ou non'), ])
@@ -52,9 +42,12 @@ 'height' => Config::get('theme.models.static_pages.banner_maxheight'), 'required' => false, 'model' => $static_pageModel ?? null, - 'helper' => __('L\'image qui va servir de bannière pour la page, format de référence : :width px max de large et :height px max de hauteur.', [ - 'width' => Config::get('theme.models.static_pages.banner_maxwidth'), 'height' => Config::get('theme.models.static_pages.banner_maxheight') - ]), + 'helper' => __( + 'L\'image qui va servir de bannière pour la page, format de référence : :width px max de large et :height px max de hauteur.', + [ + 'width' => Config::get('theme.models.static_pages.banner_maxwidth'), + 'height' => Config::get('theme.models.static_pages.banner_maxheight'), + ]), 'required' => true, 'preview' => true, ]) @@ -63,7 +56,7 @@ {{-- TEXT --}} -
+