Explorar el Código

refactored products sku table

Alexander Musikhin hace 8 meses
padre
commit
078c7026f0

+ 1 - 0
app/Models/ProductSKU.php

@@ -10,6 +10,7 @@ class ProductSKU extends Model
     use SoftDeletes;
     protected $fillable = [
         'product_id',
+        'order_id',
         'status',
         'rfid',
         'factory_number',

+ 4 - 0
database/migrations/2024_12_19_145335_create_products_sku_table.php → database/migrations/2025_03_31_145335_create_products_sku_table.php

@@ -17,6 +17,10 @@ return new class extends Migration
             $table->id();
             $table->foreignId('product_id')                             // id продукта
                 ->constrained('products')->restrictOnDelete();
+            $table->foreignId('order_id')                               // id заказа
+                ->nullable()
+                ->constrained('orders')
+                ->nullOnDelete();
             $table->string('status')->nullable();                       // ordered, shipped, stock
             $table->string('rfid')->nullable();                         // номер RFID метки
             $table->string('factory_number')->nullable();               // номер заказа на фабрике

+ 2 - 2
resources/views/orders/edit.blade.php

@@ -64,7 +64,7 @@
                                         <input class="form-control text-end form-control-sm quantity" type="number" name="quantity[]" value="{{ $p->pivot->quantity }}">
                                     </div>
                                     <div class="p-1">
-                                        <i onclick="$(this).parent().remove(); $('.changes-message').removeClass('visually-hidden');" class="bi bi-trash text-danger cursor-pointer"></i>
+                                        <i onclick="$(this).parent().parent().parent().remove(); $('.changes-message').removeClass('visually-hidden');" class="bi bi-trash text-danger cursor-pointer"></i>
                                     </div>
                                 </div>
                             </div>
@@ -114,7 +114,7 @@
                         '<input class="form-control text-end form-control-sm quantity" type="number" name="quantity[]" value="1">' +
                     '</div>' +
                     '<div class="p-1">' +
-                        '<i onclick="$(this).parent().remove();" class="bi bi-trash text-danger cursor-pointer"></i>' +
+                        '<i onclick="$(this).parent().parent().parent().remove();" class="bi bi-trash text-danger cursor-pointer"></i>' +
                     '</div>' +
                 '</div>'
             );