From 1d5659b20201a0212fa444be4e676161b23628a4 Mon Sep 17 00:00:00 2001 From: Karl Date: Tue, 3 Jun 2025 16:29:08 +0200 Subject: [PATCH] feat: delete the shelf in range and brand models --- app/Http/Controllers/Bo/ProductController.php | 1 - app/Http/Controllers/Bo/RangeController.php | 1 - .../Requests/Bo/Brands/StoreBrandRequest.php | 3 -- .../Requests/Bo/Ranges/StoreRangeRequest.php | 3 -- app/Models/Brand.php | 3 -- app/Models/Range.php | 3 -- ..._06_03_160157_remove_shelf_field_table.php | 34 +++++++++++++++++++ .../views/bo/pages/brands/form.blade.php | 18 ---------- .../bo/pages/brands/index-list.blade.php | 8 ----- .../views/bo/pages/products/edit.blade.php | 8 ----- .../bo/pages/products/index-list.blade.php | 13 +------ .../views/bo/pages/ranges/edit.blade.php | 8 ----- .../views/bo/pages/ranges/form.blade.php | 19 ----------- .../bo/pages/ranges/index-list.blade.php | 19 +---------- 14 files changed, 36 insertions(+), 105 deletions(-) create mode 100644 database/migrations/2025_06_03_160157_remove_shelf_field_table.php diff --git a/app/Http/Controllers/Bo/ProductController.php b/app/Http/Controllers/Bo/ProductController.php index 4a953d2..a5e2619 100644 --- a/app/Http/Controllers/Bo/ProductController.php +++ b/app/Http/Controllers/Bo/ProductController.php @@ -35,7 +35,6 @@ class ProductController extends Controller /** @var \Illuminate\Database\Eloquent\Builder $query */ $query = Product::query()->with(['range', 'brand'])->withCount([ 'range as parent_published' => fn(Builder $q) => $q->where('ranges.status', true), - 'range as parent_shelf' => fn(Builder $q) => $q->where('ranges.shelf', true), 'brand as parent_parent_published' => fn(Builder $q) => $q->where('brands.status', true), ]); diff --git a/app/Http/Controllers/Bo/RangeController.php b/app/Http/Controllers/Bo/RangeController.php index 625a43c..f7155e0 100644 --- a/app/Http/Controllers/Bo/RangeController.php +++ b/app/Http/Controllers/Bo/RangeController.php @@ -40,7 +40,6 @@ class RangeController extends Controller $query = Range::query()->with(['brand', 'font'])->withCount([ 'products', 'products as published_products' => fn(Builder $q) => $q->where('products.status', true), - 'brand as parent_shelf' => fn(Builder $q) => $q->where('shelf', true), 'brand as parent_published' => fn(Builder $q) => $q->where('status', true), ]); diff --git a/app/Http/Requests/Bo/Brands/StoreBrandRequest.php b/app/Http/Requests/Bo/Brands/StoreBrandRequest.php index c03d52e..1852de4 100644 --- a/app/Http/Requests/Bo/Brands/StoreBrandRequest.php +++ b/app/Http/Requests/Bo/Brands/StoreBrandRequest.php @@ -31,7 +31,6 @@ class StoreBrandRequest extends FormRequest { $this->mergePicture('picture'); $this->merge([ - 'shelf' => $this->boolean('shelf'), 'status' => $this->boolean('status') ]); } @@ -46,7 +45,6 @@ class StoreBrandRequest extends FormRequest $rules = [ 'name' => 'required|min:2|max:60', 'color' => ['required', new Hex()], - 'shelf' => 'present|boolean', 'status' => 'present|boolean' ]; @@ -66,7 +64,6 @@ class StoreBrandRequest extends FormRequest return [ 'color' => trans('validation.custom.color'), 'status' => \trans('validation.custom.status'), - 'shelf' => \trans('validation.custom.shelf'), ]; } } diff --git a/app/Http/Requests/Bo/Ranges/StoreRangeRequest.php b/app/Http/Requests/Bo/Ranges/StoreRangeRequest.php index f8dc112..74e0ab7 100644 --- a/app/Http/Requests/Bo/Ranges/StoreRangeRequest.php +++ b/app/Http/Requests/Bo/Ranges/StoreRangeRequest.php @@ -31,7 +31,6 @@ class StoreRangeRequest extends FormRequest { $this->mergePicture('picture'); $this->merge([ - 'shelf' => $this->boolean('shelf'), 'status' => $this->boolean('status') ]); } @@ -49,7 +48,6 @@ class StoreRangeRequest extends FormRequest 'font_id' => 'required|exists:fonts,id', 'color' => ['required', new Hex()], 'width' => 'required|numeric|min:1|max:2', - 'shelf' => 'present|boolean', 'status' => 'present|boolean', ]; @@ -72,7 +70,6 @@ class StoreRangeRequest extends FormRequest 'color' => \trans('validation.custom.color'), 'width' => \trans('validation.custom.width'), 'status' => \trans('validation.custom.status'), - 'shelf' => \trans('validation.custom.shelf'), ]; } } diff --git a/app/Models/Brand.php b/app/Models/Brand.php index 9b1e278..0f12054 100644 --- a/app/Models/Brand.php +++ b/app/Models/Brand.php @@ -21,7 +21,6 @@ use Illuminate\Http\UploadedFile; * @property string $slug Slug of the name for the brand. * @property string $color HTML Color string. * @property string $picture Picture path for the brand. - * @property boolean $shelf Les enfant sont rendus sur un étagere. * @property boolean $status Visible ? (présent dans l'export). * @property string $tenant_id Id of the related tenant. * @property-read \Illuminate\Support\Carbon $created_at Created date. @@ -45,7 +44,6 @@ class Brand extends Model 'name', 'color', 'picture', - 'shelf', 'status', ]; @@ -66,7 +64,6 @@ class Brand extends Model */ protected $casts = [ 'color' => HtmlColor::class, - 'shelf' => 'bool', 'status' => 'bool', ]; diff --git a/app/Models/Range.php b/app/Models/Range.php index 720a876..eb66c67 100644 --- a/app/Models/Range.php +++ b/app/Models/Range.php @@ -23,7 +23,6 @@ use App\Helpers\ShowroomFileHelper; * @property integer $width Width or the range to display * (1 or 2 columns, 2 is full width). * @property integer $order Order for the range to display. - * @property boolean $shelf Les enfant sont rendus sur un étagere. * @property boolean $status Visible ? (présent dans l'export). * @property string $tenant_id Id of the related tenant. * @property-read \Illuminate\Support\Carbon $created_at Created date. @@ -53,7 +52,6 @@ class Range extends Model 'color', 'width', 'order', - 'shelf', 'status', ]; @@ -73,7 +71,6 @@ class Range extends Model * @var array */ protected $casts = [ - 'shelf' => 'bool', 'status' => 'bool', ]; diff --git a/database/migrations/2025_06_03_160157_remove_shelf_field_table.php b/database/migrations/2025_06_03_160157_remove_shelf_field_table.php new file mode 100644 index 0000000..ee77077 --- /dev/null +++ b/database/migrations/2025_06_03_160157_remove_shelf_field_table.php @@ -0,0 +1,34 @@ +dropColumn('shelf'); + }); + Schema::table('ranges', function (Blueprint $table) { + $table->dropColumn('shelf'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('brands', function (Blueprint $table) { + $table->boolean('shelf')->comment('Les enfant sont rendus sur un étagere.'); + }); + Schema::table('ranges', function (Blueprint $table) { + $table->boolean('shelf')->comment('Les enfant sont rendus sur un étagere.'); + }); + } +}; diff --git a/resources/views/bo/pages/brands/form.blade.php b/resources/views/bo/pages/brands/form.blade.php index 7b9e74a..6dddb6f 100644 --- a/resources/views/bo/pages/brands/form.blade.php +++ b/resources/views/bo/pages/brands/form.blade.php @@ -85,24 +85,6 @@ - {{-- SHELF --}} -
-
- {{ Str::ucfirst(__('validation.custom.shelf')) }} -
-
- @include('bo.partials.inputs.tinyint-boolean', [ - 'id' => 'brandShelf', - 'name' => 'shelf', - 'label' => __('Afficher sur une étagère'), - 'helper' => __('Les modèles enfant seront affichés sur une étagère'), - 'model' => $brandModel ?? null, - 'default' => true, - ]) -
-
-
-
{{-- STATUS --}}
diff --git a/resources/views/bo/pages/brands/index-list.blade.php b/resources/views/bo/pages/brands/index-list.blade.php index b665d91..8512930 100644 --- a/resources/views/bo/pages/brands/index-list.blade.php +++ b/resources/views/bo/pages/brands/index-list.blade.php @@ -5,7 +5,6 @@ 'cols' => [ 'name' => Str::ucfirst(__('validation.attributes.name')), 'color' => Str::ucfirst(__('validation.custom.color')), - 'shelf' => Str::ucfirst(__('validation.custom.shelf')), 'status' => Str::ucfirst(__('validation.custom.status')), 'updated_at' => Str::ucfirst(__('validation.attributes.updated_at')), ], @@ -34,13 +33,6 @@ {{ $brandModel->color }} - - @if ($brandModel->shelf) - {{ __('Oui') }} - @else - {{ __('Non') }} - @endif - @if ($brandModel->status) diff --git a/resources/views/bo/pages/products/edit.blade.php b/resources/views/bo/pages/products/edit.blade.php index 5ec0c73..32c871a 100644 --- a/resources/views/bo/pages/products/edit.blade.php +++ b/resources/views/bo/pages/products/edit.blade.php @@ -61,14 +61,6 @@ {{ $productModel->range->name }}
- - {{ Str::ucfirst(__('validation.custom.shelf')) }} :  - @if ($productModel->range->shelf) - {{ __('Oui') }} - @else - {{ __('Non') }} - @endif - diff --git a/resources/views/bo/pages/products/index-list.blade.php b/resources/views/bo/pages/products/index-list.blade.php index e88dc63..69e2b20 100644 --- a/resources/views/bo/pages/products/index-list.blade.php +++ b/resources/views/bo/pages/products/index-list.blade.php @@ -6,11 +6,10 @@ 'name' => Str::ucfirst(__('validation.attributes.name')), 'range_id' => Str::ucfirst(trans_choice('models.classes.range', 1)), 'brand_id' => Str::ucfirst(trans_choice('models.classes.brand', 1)), - 'shelf' => Str::ucfirst(__('validation.custom.shelf')), 'status' => Str::ucfirst(__('validation.custom.status')), 'updated_at' => Str::ucfirst(__('validation.attributes.updated_at')), ], - 'ignore' => ['brand_id', 'shelf'], + 'ignore' => ['brand_id'], ]) @@ -40,16 +39,6 @@ {{ Str::limit($productModel->brand->name, 35) }} - - - {{ __('Parent') }} :  - @if ($productModel->parent_shelf) - {{ __('Oui') }} - @else - {{ __('Non') }} - @endif - - @if ($productModel->status) diff --git a/resources/views/bo/pages/ranges/edit.blade.php b/resources/views/bo/pages/ranges/edit.blade.php index 55c2b22..a4cbc28 100644 --- a/resources/views/bo/pages/ranges/edit.blade.php +++ b/resources/views/bo/pages/ranges/edit.blade.php @@ -62,14 +62,6 @@ {{ __('Parent') }} {{ $rangeModel->brand->name }} - - {{ Str::ucfirst(__('validation.custom.shelf')) }} :  - @if ($rangeModel->brand->shelf) - {{ __('Oui') }} - @else - {{ __('Non') }} - @endif - diff --git a/resources/views/bo/pages/ranges/form.blade.php b/resources/views/bo/pages/ranges/form.blade.php index 99ce7c0..891aea0 100644 --- a/resources/views/bo/pages/ranges/form.blade.php +++ b/resources/views/bo/pages/ranges/form.blade.php @@ -147,25 +147,6 @@ - {{-- SHELF --}} -
-
- {{ Str::ucfirst(__('validation.custom.shelf')) }} -
-
- @include('bo.partials.inputs.tinyint-boolean', [ - 'id' => 'productShelf', - 'name' => 'shelf', - 'label' => __('Afficher sur une étagère'), - 'helper' => __('Les modèles enfant seront affichés sur une étagère'), - 'model' => $rangeModel ?? null, - 'default' => true, - ]) -
-
-
-
- {{-- STATUS --}}
diff --git a/resources/views/bo/pages/ranges/index-list.blade.php b/resources/views/bo/pages/ranges/index-list.blade.php index caaf6bf..2da54c4 100644 --- a/resources/views/bo/pages/ranges/index-list.blade.php +++ b/resources/views/bo/pages/ranges/index-list.blade.php @@ -5,7 +5,6 @@ 'cols' => [ 'name' => Str::ucfirst(__('validation.attributes.name')), 'brand_id' => Str::ucfirst(trans_choice('models.classes.brand', 1)), - 'shelf' => Str::ucfirst(__('validation.custom.shelf')), 'width' => Str::ucfirst(__('validation.custom.width')), 'status' => Str::ucfirst(__('validation.custom.status')), 'order' => Str::ucfirst(__('validation.custom.order')), @@ -48,23 +47,7 @@ {{ Str::limit($rangeModel->brand->name, 35) }} - - - @if ($rangeModel->shelf) - {{ __('Oui') }} - @else - {{ __('Non') }} - @endif - - - {{ __('Parent') }} :  - @if ($rangeModel->parent_shelf) - {{ __('Oui') }} - @else - {{ __('Non') }} - @endif - - + {{ 50 * $rangeModel->width }} %