feat: delete nutritionnal_value from bo and fo 🔥 one migration has to pass
This commit is contained in:
parent
fcdf1b85e8
commit
5968541086
8 changed files with 32 additions and 76 deletions
|
|
@ -97,19 +97,6 @@ class StoreProductRequest extends FormRequest
|
|||
],
|
||||
'caliber.*' => 'required|array',
|
||||
'caliber.*.value' => 'required|string|min:1|max:255',
|
||||
'nutritionnal_values' => [
|
||||
'present',
|
||||
'array',
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||
function ($attribute, array $value, $fail) {
|
||||
if (count($value) != 9) {
|
||||
$fail(\trans('Vous devez remplir seulement 9 lignes de valeurs nutritionnelles.'));
|
||||
}
|
||||
}
|
||||
],
|
||||
'nutritionnal_values.*' => 'nullable|array',
|
||||
'nutritionnal_values.*.label' => 'nullable|string|min:3|max:255',
|
||||
'nutritionnal_values.*.value' => 'nullable|numeric|min:0',
|
||||
'is_frenchpoultry' => 'required|boolean',
|
||||
'is_vip' => 'required|boolean',
|
||||
'is_egalim' => 'required|boolean',
|
||||
|
|
@ -146,9 +133,6 @@ class StoreProductRequest extends FormRequest
|
|||
'packaging.*.value' => trans('valeur du conditionnement'),
|
||||
'caliber' => trans('calibre'),
|
||||
'caliber.*.value' => trans('valeur du calibre'),
|
||||
'nutritionnal_values' => trans('valeurs nutritionnelles'),
|
||||
'nutritionnal_values.*.label' => trans('libellé de la valeur nutritionnelle'),
|
||||
'nutritionnal_values.*.value' => trans('valeur de la valeur nutritionnelle'),
|
||||
'is_frenchpoultry' => trans('Label volaille française'),
|
||||
'is_vip' => trans('Produit VIP'),
|
||||
'is_egalim' => trans('Produit Égalim'),
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ class ProductCommercialSheetResource extends JsonResource
|
|||
'ingredients' => '',
|
||||
'preparation' => '',
|
||||
'sticker_sm' => '',
|
||||
'nutritionnal_values' => [],
|
||||
'slider_pictures' => [],
|
||||
'subrange' => null,
|
||||
];
|
||||
|
|
@ -65,7 +64,6 @@ class ProductCommercialSheetResource extends JsonResource
|
|||
'caliber' => $this->product->caliber,
|
||||
'ingredients' => $this->product->ingredients,
|
||||
'preparation' => $this->product->preparation,
|
||||
'nutritionnal_values' => $this->product->nutritionnal_values,
|
||||
'sticker_sm' => $this->product->sticker_sm,
|
||||
'slider_pictures' => $this->product->slider_pictures,
|
||||
'subrange' => (new SubrangeResource($this->product->subrange))->toArray($request),
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ use Uwil\SitemapGenerator\Lib\SitemapHelper;
|
|||
* @property array<string> $slider_pictures Array of paths of pictures.
|
||||
* @property array<array<string,string>> $packaging Packaging.
|
||||
* @property array<array<string,string>> $caliber Caliber.
|
||||
* @property array<array<string,string>> $nutritionnal_values Nutritionnal values.
|
||||
* @property string $ingredients Ingredients.
|
||||
* @property string $advantage Advantage.
|
||||
* @property string $preparation Preparation.
|
||||
|
|
@ -77,7 +76,6 @@ class Product extends Model implements SeoInterface, Sitemapable
|
|||
'slider_pictures',
|
||||
'packaging',
|
||||
'caliber',
|
||||
'nutritionnal_values',
|
||||
'is_frenchpoultry',
|
||||
'is_vip',
|
||||
'is_egalim',
|
||||
|
|
@ -93,7 +91,6 @@ class Product extends Model implements SeoInterface, Sitemapable
|
|||
'slider_pictures' => 'array',
|
||||
'packaging' => 'array',
|
||||
'caliber' => 'array',
|
||||
'nutritionnal_values' => 'array',
|
||||
'is_frenchpoultry' => 'bool',
|
||||
'is_vip' => 'bool',
|
||||
'is_egalim' => 'bool',
|
||||
|
|
@ -154,11 +151,6 @@ class Product extends Model implements SeoInterface, Sitemapable
|
|||
foreach ($model->caliber as $calib) {
|
||||
ToolboxHelper::assertNoInternalBoUrls('caliber', $calib['value']);
|
||||
}
|
||||
foreach ($model->nutritionnal_values as $nutritionnal_value) {
|
||||
if (!empty($nutritionnal_value['value'])) {
|
||||
ToolboxHelper::assertNoInternalBoUrls('nutritionnal_values', $nutritionnal_value['value']);
|
||||
}
|
||||
}
|
||||
|
||||
// * TRANSFORMATIONS
|
||||
$model->slug = Str::slug($model->label);
|
||||
|
|
@ -169,7 +161,6 @@ class Product extends Model implements SeoInterface, Sitemapable
|
|||
$model->slider_pictures = clean($model->slider_pictures);
|
||||
$model->packaging = clean($model->packaging);
|
||||
$model->caliber = clean($model->caliber);
|
||||
$model->nutritionnal_values = clean($model->nutritionnal_values);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -38,14 +38,6 @@ class ProductFactory extends Factory
|
|||
]);
|
||||
}
|
||||
|
||||
$nutritionnal_values = [];
|
||||
for ($jj = 1; $jj <= 9; $jj++) {
|
||||
array_push($nutritionnal_values, [
|
||||
"label" => $this->faker->unique()->words(rand(2, 8), true),
|
||||
"value" => $this->faker->numberBetween(6, 30)
|
||||
]);
|
||||
}
|
||||
|
||||
$label = $this->faker->unique()->words(rand(2, 4), true);
|
||||
|
||||
return [
|
||||
|
|
@ -59,7 +51,6 @@ class ProductFactory extends Factory
|
|||
'sticker_sm_alt' => $this->faker->words(8, true),
|
||||
'packaging' => $packaging,
|
||||
'caliber' => $caliber,
|
||||
'nutritionnal_values' => $nutritionnal_values,
|
||||
'ingredients' => $this->faker->unique()->words(rand(15, 25), true),
|
||||
'advantage' => $this->faker->unique()->words(rand(15, 25), true),
|
||||
'preparation' => $this->faker->unique()->words(rand(15, 25), true),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropColumn('nutritionnal_values');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->json('nutritionnal_values')->comment('Valeurs nutritionnelles du produit')->nullable();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -177,7 +177,6 @@ return [
|
|||
'ingredients' => 'Ingrédients',
|
||||
'label' => 'Libellé',
|
||||
'link' => 'Lien',
|
||||
'nutritionnal_values' => 'Valeurs nutritionnelles',
|
||||
'order' => 'Ordre',
|
||||
'packaging' => 'Conditionnement',
|
||||
'page' => 'Espèce',
|
||||
|
|
|
|||
|
|
@ -345,33 +345,6 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- NUTRITIONNAL VALUES --}}
|
||||
<div class="col-12 pb-3">
|
||||
<fieldset class="h-100 border bg-white p-3">
|
||||
<legend>{{ __('Valeurs nutritionnelles') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
@include('bo.partials.inputs.text-list-items', [
|
||||
'id' => 'productNutritionnalValues',
|
||||
'name' => 'nutritionnal_values',
|
||||
'label' => Str::ucfirst(__('validation.attributes.nutritionnal_values')),
|
||||
'model' => $productModel ?? null,
|
||||
'itemColumns' => [['label', 'Libellé'], ['value', 'Valeur']],
|
||||
'itemType' => ['text', 'number'],
|
||||
'itemLimit' => [9, 9],
|
||||
'inputPlaceholder' => ['Sucres (en g) ', '6'],
|
||||
'required' => true,
|
||||
'helper' => __('validation.custom.list_items', [
|
||||
'field' => Str::ucfirst(__('validation.attributes.nutritionnal_values')),
|
||||
'min' => 3,
|
||||
'lineMin' => 1,
|
||||
'lineMax' => 6,
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- INDICATEURS --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="h-100 border bg-white p-3">
|
||||
|
|
|
|||
|
|
@ -84,18 +84,6 @@
|
|||
<p class="poppins-bold fs-md border-bottom mb-4 mt-5 w-fit border-2 pb-1">
|
||||
{{ __('Les atouts produit :') }}</p>
|
||||
<p class="ck-content my-3 mt-4">{!! clean($product->advantage) !!}</p>
|
||||
<p class="poppins-bold fs-md border-bottom mb-4 mt-5 w-fit border-2 pb-1">
|
||||
{{ __('Valeurs nutritionnelles moyennes pour 100g :') }}</p>
|
||||
<table class="w-100">
|
||||
<tbody>
|
||||
@foreach ($product->nutritionnal_values as $ingredient)
|
||||
<tr>
|
||||
<th>{{ $ingredient['label'] }}</th>
|
||||
<td>{{ $ingredient['value'] }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="prod-logos mb-4 mt-4">
|
||||
@if ($product->is_frenchpoultry)
|
||||
<img class="me-4" src="{{ Vite::asset('resources/assets/images/logo-vf.svg') }}"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue