From 8a3058e7bc3b0fad954ed86ec4c1911b16bd77c0 Mon Sep 17 00:00:00 2001 From: Noah Lancien Date: Tue, 5 Sep 2023 15:28:55 +0200 Subject: [PATCH] Fixed some requests from the provided excel document --- app/Http/Controllers/ProductController.php | 14 +- .../Requests/Products/StoreProductRequest.php | 5 +- app/Models/Product.php | 19 +-- ...hange_products_pvc_from_int_to_decimal.php | 32 +++++ resources/lang/fr/models.php | 1 + resources/sass/base/_common.scss | 4 +- .../ts/components/ButtonMultiPdfComponent.vue | 8 +- .../ts/components/ImageInputComponent.vue | 10 +- .../components/MultipleCommentsComponent.vue | 6 +- .../MultipleDocumentsInputComponent.vue | 28 +--- .../ts/components/SourceInputsComponent.vue | 31 +++-- .../ts/components/TastedProductComponent.vue | 11 +- .../components/VerificationCodeComponent.vue | 8 +- resources/ts/utilities/fontawesome.ts | 70 +++++----- .../views/documents/product-body.blade.php | 19 ++- resources/views/documents/product.blade.php | 9 +- resources/views/layouts/nav-menu.blade.php | 4 +- .../views/modules/table-col-sorter.blade.php | 2 - resources/views/pages/dashboard.blade.php | 6 +- .../views/pages/products/create.blade.php | 14 +- resources/views/pages/products/edit.blade.php | 16 +-- resources/views/pages/products/form.blade.php | 123 +++++++++++------- .../views/pages/products/index.blade.php | 8 +- .../views/pages/products/indexList.blade.php | 26 ++-- .../pages/products/product-filters.blade.php | 2 +- .../inputs/bigint-foreign-id.blade.php | 5 +- .../partials/inputs/int-number.blade.php | 8 +- .../partials/inputs/select-enum.blade.php | 4 +- 28 files changed, 283 insertions(+), 210 deletions(-) create mode 100644 database/migrations/2023_09_05_131123_change_products_pvc_from_int_to_decimal.php diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index bfcba2f..dacae6b 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -312,20 +312,20 @@ class ProductController extends Controller public function checkGencode(Request $request) { if ( - isset($request->GENCODE) && - $request->GENCODE !== null && - ctype_digit($request->GENCODE) && - strlen($request->GENCODE) > 0 + isset($request->GENCOD) && + $request->GENCOD !== null && + ctype_digit($request->GENCOD) && + strlen($request->GENCOD) > 0 ) { if ( isset($request->ID) && $request->ID !== null && - intval($request->GENCODE) === Product::where('id', $request->ID)->firstOrFail()->gencod + intval($request->GENCOD) === Product::where('id', $request->ID)->firstOrFail()->gencod ) { $result = null; } else { - $result = in_array(intval($request->GENCODE), Product::pluck('gencod')->toArray()) ? - Product::orderBy('created_at', 'desc')->where('gencod', intval($request->GENCODE))->first() : null; + $result = in_array(intval($request->GENCOD), Product::pluck('gencod')->toArray()) ? + Product::orderBy('created_at', 'desc')->where('gencod', intval($request->GENCOD))->first() : null; } } else { $result = null; diff --git a/app/Http/Requests/Products/StoreProductRequest.php b/app/Http/Requests/Products/StoreProductRequest.php index 8887dec..aae7317 100644 --- a/app/Http/Requests/Products/StoreProductRequest.php +++ b/app/Http/Requests/Products/StoreProductRequest.php @@ -44,6 +44,9 @@ class StoreProductRequest extends FormRequest 'is_tasted' => $this->is_tasted ? true : false, 'origins' => $this->origins ? $this->origins : [], 'claims' => $this->claims ? $this->claims : [], + 'picture_alt' => $this->name, + 'picture_title' => $this->name, + 'certification' => $this->certification == 0 ? null : $this->certification, ]); $this->mergePicture('picture'); $this->mergeDocuments('docs'); @@ -88,7 +91,7 @@ class StoreProductRequest extends FormRequest 'product_range' => ['required', new Enum(RangeEnum::class)], 'geo_area' => ['required', new Enum(GeoAreaEnum::class)], 'weight' => 'nullable|integer', - 'pvc' => 'nullable|integer', + 'pvc' => 'nullable|decimal:0,2', 'comment' => 'nullable|string|min:15', 'is_tasted' => 'required|boolean', 'tasters_number' => 'nullable|integer', diff --git a/app/Models/Product.php b/app/Models/Product.php index d0cb5e7..b47c85b 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -170,6 +170,7 @@ class Product extends Model */ private static function updateSpecifiedClaim(Product $model) { + $check = false; foreach ($model->claims as $claim) { $check = (intval($claim['id']) === \App\Enums\Products\ClaimEnum::others->value) ? true : false; } @@ -212,14 +213,16 @@ class Product extends Model */ public static function deleteOldDocuments(self $model) { - foreach ($model->getOriginal('docs') as $document) { - $originalPath = \ltrim(\urldecode($document), '/'); - if (\strpos($originalPath, 'storage') !== 0) { - return; - } - $originalPath = ToolboxHelper::mbReplace('storage/', '', $originalPath); - if (Storage::disk('public')->exists($originalPath)) { - Storage::disk('public')->delete($originalPath); + if ($model->getOriginal('docs')) { + foreach ($model->getOriginal('docs') as $document) { + $originalPath = \ltrim(\urldecode($document), '/'); + if (\strpos($originalPath, 'storage') !== 0) { + return; + } + $originalPath = ToolboxHelper::mbReplace('storage/', '', $originalPath); + if (Storage::disk('public')->exists($originalPath)) { + Storage::disk('public')->delete($originalPath); + } } } } diff --git a/database/migrations/2023_09_05_131123_change_products_pvc_from_int_to_decimal.php b/database/migrations/2023_09_05_131123_change_products_pvc_from_int_to_decimal.php new file mode 100644 index 0000000..367fee5 --- /dev/null +++ b/database/migrations/2023_09_05_131123_change_products_pvc_from_int_to_decimal.php @@ -0,0 +1,32 @@ +decimal('pvc', 12, 2)->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::table('products', function (Blueprint $table) { + $table->integer('pvc')->change(); + }); + } +}; diff --git a/resources/lang/fr/models.php b/resources/lang/fr/models.php index 6f12cf6..42342b1 100644 --- a/resources/lang/fr/models.php +++ b/resources/lang/fr/models.php @@ -3,6 +3,7 @@ return [ 'classes' => [ 'products' => 'Produits', + 'products_monitoring' => 'Veille produit|Veilles produit', 'brands' => 'Marques', ] ]; diff --git a/resources/sass/base/_common.scss b/resources/sass/base/_common.scss index b666315..a52b4d5 100644 --- a/resources/sass/base/_common.scss +++ b/resources/sass/base/_common.scss @@ -3,7 +3,9 @@ } .bo-image-preview { - max-height: 60px; + // max-height: 60px; + width: 180px; + height: auto; } .text-ellipsis { diff --git a/resources/ts/components/ButtonMultiPdfComponent.vue b/resources/ts/components/ButtonMultiPdfComponent.vue index 1c04c62..7fe8fe8 100644 --- a/resources/ts/components/ButtonMultiPdfComponent.vue +++ b/resources/ts/components/ButtonMultiPdfComponent.vue @@ -13,17 +13,19 @@ diff --git a/resources/views/pages/products/index.blade.php b/resources/views/pages/products/index.blade.php index 698104f..3197b69 100644 --- a/resources/views/pages/products/index.blade.php +++ b/resources/views/pages/products/index.blade.php @@ -1,6 +1,6 @@ @extends('layout') -@section('title', sprintf('%s - %s', __('models.classes.products'), Str::ucfirst(__('liste')))) +@section('title', sprintf('%s - %s', trans_choice('models.classes.products_monitoring', 2), Str::ucfirst(__('liste')))) @section('description', __('Liste des produits publiés')) @section('breadcrumb', 'no') @@ -10,14 +10,14 @@

- {{ __('models.classes.products') }} {{ Str::ucfirst(__('liste')) }} + {{ trans_choice('models.classes.products_monitoring', 2) }} {{ Str::ucfirst(__('liste')) }}

diff --git a/resources/views/pages/products/indexList.blade.php b/resources/views/pages/products/indexList.blade.php index df579d2..f363e0e 100644 --- a/resources/views/pages/products/indexList.blade.php +++ b/resources/views/pages/products/indexList.blade.php @@ -6,8 +6,7 @@ 'name' => __('Nom'), 'brand_id' => __('Marque'), 'picture' => __('Image'), - 'updated_at' => __('Mis à jour le'), - 'multi_pdf' => __('Multi .pdf'), + 'multi_pdf' => __('Générer en pdf la sélection'), ]; $routeName = request()->route()->getName(); $rst = !is_null(request()->rst) || !Session::has("$routeName.sorted"); @@ -37,12 +36,7 @@

{{ __('Aucune image enregistée') }}

@endif - - - {{ $productModel->updated_at->formatLocalized('%d/%m/%Y à %I:%M') }} - - - @if(!$noOrder or $rst) + {{-- @if(!$noOrder or $rst) --}} @php $data = [ @@ -53,7 +47,7 @@ @endphp
- @endif + {{-- @endif --}}
@method('DELETE') @@ -62,38 +56,38 @@ @@ -106,7 +100,7 @@ {{ __('Aucun résultat pour les :models', ['models' => __('models.classes.products')]) }} + class="h3">{{ __('Aucun résultat pour les :models', ['models' => trans_choice('models.classes.products_monitoring', 2)]) }} diff --git a/resources/views/pages/products/product-filters.blade.php b/resources/views/pages/products/product-filters.blade.php index 7214175..430f80d 100644 --- a/resources/views/pages/products/product-filters.blade.php +++ b/resources/views/pages/products/product-filters.blade.php @@ -33,7 +33,7 @@
- +
diff --git a/resources/views/partials/inputs/bigint-foreign-id.blade.php b/resources/views/partials/inputs/bigint-foreign-id.blade.php index 1a665d6..0cab24a 100644 --- a/resources/views/partials/inputs/bigint-foreign-id.blade.php +++ b/resources/views/partials/inputs/bigint-foreign-id.blade.php @@ -1,9 +1,12 @@ @if(!empty($label)) @endif +{{-- @dd($model->{$name}) --}} + @foreach ($associatedModels as $associatedModel) - @endforeach