Add marinade field to product
This commit is contained in:
parent
18ece16c63
commit
83103eff7c
8 changed files with 64 additions and 1 deletions
|
|
@ -50,6 +50,7 @@ class StoreProductRequest extends FormRequest
|
|||
'label' => 'required|min:3|max:255',
|
||||
'slug' => 'unique_translation:products',
|
||||
'description' => 'required|string|min:15',
|
||||
'marinade' => 'nullable|string|min:15',
|
||||
'picture_alt' => 'required|min:3|max:255',
|
||||
'picture_title' => 'required|min:3|max:255',
|
||||
'certifications' => 'present|array',
|
||||
|
|
@ -97,6 +98,7 @@ class StoreProductRequest extends FormRequest
|
|||
'label' => trans('label'),
|
||||
'slug' => trans('slug'),
|
||||
'description' => trans('description'),
|
||||
'marinade' => trans('marinade'),
|
||||
'picture_alt' => trans('picture_alt'),
|
||||
'picture_title' => trans('picture_title'),
|
||||
'certifications' => trans('certifications'),
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class UpdateProductRequest extends StoreProductRequest
|
|||
'label' => 'required|min:3|max:255',
|
||||
'slug' => UniqueTranslationRule::for('products')->ignore($this->product->id),
|
||||
'description' => 'required|string|min:15',
|
||||
'marinade' => 'nullable|string|min:15',
|
||||
'picture_alt' => 'required|min:3|max:255',
|
||||
'picture_title' => 'required|min:3|max:255',
|
||||
'certifications' => 'present|array',
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use Illuminate\Support\Str;
|
|||
* @property string $label
|
||||
* @property string $slug
|
||||
* @property string $description
|
||||
* @property string|null $marinade
|
||||
* @property string $picture
|
||||
* @property array $certifications
|
||||
* @property array $nutritionnal_values
|
||||
|
|
@ -40,6 +41,7 @@ class Product extends Model
|
|||
'label',
|
||||
'slug',
|
||||
'description',
|
||||
'marinade',
|
||||
'picture',
|
||||
'picture_alt',
|
||||
'picture_title',
|
||||
|
|
@ -74,6 +76,7 @@ class Product extends Model
|
|||
'label',
|
||||
'slug',
|
||||
'description',
|
||||
'marinade',
|
||||
'picture',
|
||||
'picture_alt',
|
||||
'picture_title',
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ final class ProductFactory extends Factory
|
|||
'label' => $label,
|
||||
'slug' => Str::slug($label),
|
||||
'description' => fake()->word,
|
||||
'marinade' => fake()->boolean() ? fake()->word : null,
|
||||
'picture_alt' => fake()->word,
|
||||
'picture_title' => fake()->word,
|
||||
'certifications' => [\collect(CertificationsEnum::cases())->random()],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
<?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->text('marinade', 'Marinade champs migré sur la fin non demandé par le client')
|
||||
->nullable()->after('description');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropColumn('marinade');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -186,6 +186,24 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- MARINADE --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="border bg-white p-3">
|
||||
<legend>{{ __('Marinade') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.text-html', [
|
||||
'id' => 'productMarinade',
|
||||
'label' => __('Marinade of the :model', ['model' => Str::singular(__('models.classes.products'))]),
|
||||
'name' => 'marinade',
|
||||
'model' => $productModel ?? null,
|
||||
'required' => false,
|
||||
'helper' => __('Proofread your content before publishing it (minimum 15 characters).'),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- PICTURE --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@
|
|||
</ul>
|
||||
@endforeach
|
||||
</div>
|
||||
@if ($productModel->marinade)
|
||||
<div id="marinade" class="col-span-2 mt-4 ck-content">
|
||||
{!! clean($productModel->marinade) !!}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ Route::prefix('bo')
|
|||
// * PRODUCTS
|
||||
Route::resource('products', ProductController::class)->except(['show'])
|
||||
->withoutMiddleware('htmlsanitize')
|
||||
->middleware(['htmlsanitize:description']);
|
||||
->middleware(['htmlsanitize:description,marinade']);
|
||||
Route::post('/products/{product}/change-order', [ProductController::class, 'changeOrder'])
|
||||
->name('products.change-order');
|
||||
Route::post('/products/{product}/change-published', [ProductController::class, 'changePublished'])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue