浏览代码

products.type nullable

Alexander Musikhin 5 天之前
父节点
当前提交
a228c2d23e

+ 28 - 0
database/migrations/2026_01_23_202752_make_type_nullable_in_products_table.php

@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::table('products', function (Blueprint $table) {
+            $table->string('type')->nullable()->change();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::table('products', function (Blueprint $table) {
+            $table->string('type')->nullable(false)->default('Товар')->change();
+        });
+    }
+};

+ 1 - 1
resources/views/catalog/edit.blade.php

@@ -30,7 +30,7 @@
                         @include('partials.input', ['name' => 'type_tz', 'title' => 'Тип по ТЗ', 'required' => true, 'value' => $product->type_tz ?? '', 'disabled' => !hasRole('admin')])
                         @include('partials.input', ['name' => 'unit', 'title' => 'Ед. изм.', 'required' => true, 'value' => $product->unit ?? '', 'disabled' => !hasRole('admin')])
                         @include('partials.input', ['name' => 'manufacturer', 'title' => 'Производитель', 'required' => true, 'value' => $product->manufacturer ?? '', 'disabled' => !hasRole('admin')])
-                        @include('partials.input', ['name' => 'type', 'title' => 'Тип', 'required' => true, 'value' => $product->type ?? '', 'disabled' => !hasRole('admin')])
+                        @include('partials.input', ['name' => 'type', 'title' => 'Тип', 'value' => $product->type ?? '', 'disabled' => !hasRole('admin')])
                         @include('partials.input', ['name' => 'manufacturer_name', 'title' => 'Наименование производителя', 'required' => true, 'value' => $product->manufacturer_name ?? '', 'disabled' => !hasRole('admin')])
                         @include('partials.input', ['name' => 'sizes', 'title' => 'Размеры', 'required' => true, 'value' => $product->sizes ?? '', 'disabled' => !hasRole('admin')])
                         @include('partials.input', ['name' => 'product_price', 'type' => 'number', 'title' => 'Цена товара', 'required' => true, 'value' => $product->product_price ?? '', 'disabled' => !hasRole('admin')])