From ef44546aea1c7bde9434fe04a6d51f4214d08ab4 Mon Sep 17 00:00:00 2001 From: Corentin Huet Date: Fri, 27 Mar 2026 14:22:54 +0100 Subject: [PATCH] fix: :bug: correct publish validation, fix translation, and add slider indicators --- app/Models/Aisle.php | 4 +++- app/Models/Brand.php | 6 ++++-- app/Models/Network.php | 4 +++- resources/lang/fr/validation.php | 3 ++- resources/views/bo/pages/brands/form.blade.php | 6 +++--- resources/views/fo/pages/networks/show.blade.php | 3 +++ 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/Models/Aisle.php b/app/Models/Aisle.php index 17d0287..46b7b35 100644 --- a/app/Models/Aisle.php +++ b/app/Models/Aisle.php @@ -94,9 +94,11 @@ class Aisle extends Model private static function assertLimitPublishedModels(self $model, bool $isDeletion = false) { $count = self::query()->where('published', true)->where('network_id', $model->network_id)->count(); + $updatePublished = !$isDeletion && $model->published && !$model->getOriginal('published'); + if ( (!$model->published && $count <= 1) || - ($model->published && $count >= 4) || + ($updatePublished && $count >= 4) || ($isDeletion && $count === 1) ) { throw ValidationException::withMessages([ diff --git a/app/Models/Brand.php b/app/Models/Brand.php index 90baf1a..d583ef0 100644 --- a/app/Models/Brand.php +++ b/app/Models/Brand.php @@ -89,11 +89,13 @@ class Brand extends Model */ private static function assertLimitPublishedModels(self $model, bool $isDeletion = false) { - $count = self::query()->where('published', true)->count(); + $count = self::query()->where('published', true)->where('aisle_id', $model->aisle_id)->count(); + $updatePublished = !$isDeletion && $model->published && !$model->getOriginal('published'); + if ( $count !== 0 && ((!$model->published && $count <= 1) || - ($model->published && $count >= 5) || + ($updatePublished && $count >= 5) || ($isDeletion && $count === 1)) ) { throw ValidationException::withMessages([ diff --git a/app/Models/Network.php b/app/Models/Network.php index e4d9397..0d1535f 100644 --- a/app/Models/Network.php +++ b/app/Models/Network.php @@ -138,9 +138,11 @@ class Network extends Model private static function assertLimitPublishedModels(self $model, bool $isDeletion = false) { $count = self::query()->where('published', true)->count(); + $updatePublished = !$isDeletion && $model->published && !$model->getOriginal('published'); + if ( (!$model->published && $count <= 1) || - ($model->published && $count >= 5) || + ($updatePublished && $count >= 5) || ($isDeletion && $count === 1) ) { throw ValidationException::withMessages([ diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php index dfb5e68..962a5a5 100644 --- a/resources/lang/fr/validation.php +++ b/resources/lang/fr/validation.php @@ -303,6 +303,7 @@ return [ 'link' => 'lien de l\'ancre', ], 'media' => 'média', - 'anchor' => 'ancre' + 'anchor' => 'ancre', + 'link' => 'lien', ], ]; diff --git a/resources/views/bo/pages/brands/form.blade.php b/resources/views/bo/pages/brands/form.blade.php index ed73c4c..fe868ed 100644 --- a/resources/views/bo/pages/brands/form.blade.php +++ b/resources/views/bo/pages/brands/form.blade.php @@ -34,13 +34,13 @@ {{-- LINK --}}
- {{ Str::ucfirst(__('validation.attributes.link')) }} + {{ Str::ucfirst(__('validation.custom.link')) }}
@include('bo.partials.inputs.varchar', [ 'id' => 'brandLink', 'label' => __(':field :inter:model', [ - 'field' => Str::ucfirst(__('validation.attributes.link')), + 'field' => Str::ucfirst(__('validation.custom.link')), 'inter' => __('validation.custom.of_the.female'), 'model' => trans_choice('models.classes.brand', 1), ]), @@ -50,7 +50,7 @@ 'model' => $brandModel ?? null, 'helper' => __('validation.between.string', [ 'attribute' => __(':field :inter:model', [ - 'field' => __('validation.attributes.link'), + 'field' => __('validation.custom.link'), 'inter' => __('validation.custom.of_the.female'), 'model' => trans_choice('models.classes.brand', 1), ]), diff --git a/resources/views/fo/pages/networks/show.blade.php b/resources/views/fo/pages/networks/show.blade.php index 35cd42a..3a3bc1d 100644 --- a/resources/views/fo/pages/networks/show.blade.php +++ b/resources/views/fo/pages/networks/show.blade.php @@ -102,6 +102,9 @@
@endforeach
+
+