瀏覽代碼

Updated products sku migration and model

Alexander Musikhin 9 月之前
父節點
當前提交
f118be27c2

+ 12 - 1
app/Models/ProductSKU.php

@@ -8,6 +8,17 @@ use Illuminate\Database\Eloquent\SoftDeletes;
 class ProductSKU extends Model
 {
     use SoftDeletes;
-    protected $guarded = false;
+    protected $fillable = [
+        'product_id',
+        'status',
+        'rfid',
+        'factory_number',
+        'manufacture_date',
+        'service_life',
+        'certificate_number',
+        'certificate_date',
+        'certificate_issuer',
+        'certificate_type',
+    ];
     public $table = 'products_sku';
 }

+ 11 - 9
database/migrations/2024_12_19_145335_create_products_sku_table.php

@@ -15,15 +15,17 @@ return new class extends Migration
     {
         Schema::create('products_sku', function (Blueprint $table) {
             $table->id();
-            $table->foreignId('product_id')->constrained('products')->restrictOnDelete();
-            $table->string('status'); // ordered, stock, shipped
-            $table->string('rfid');
-            $table->string('factory_number');
-            $table->date('manufacture_date');
-            $table->unsignedInteger('service_life'); //срок эксплуатации
-            $table->string('certificate_number');
-            $table->date('certificate_date');
-            $table->string('certificate_issuer');
+            $table->foreignId('product_id')                             // id продукта
+                ->constrained('products')->restrictOnDelete();
+            $table->string('status')->nullable();                       // ordered, shipped, stock
+            $table->string('rfid')->nullable();                         // номер RFID метки
+            $table->string('factory_number')->nullable();               // номер заказа на фабрике
+            $table->date('manufacture_date')->nullable();               // дата производства
+            $table->unsignedInteger('service_life')->nullable();        // срок эксплуатации, месяцев
+            $table->string('certificate_number')->nullable();           // номер сертификата
+            $table->date('certificate_date')->nullable();               // дата выдачи сертификата
+            $table->string('certificate_issuer')->nullable();           // орган сертификации
+            $table->string('certificate_type')->nullable();             // декларация, сертификат, отказное письмо
 
             $table->softDeletes();
             $table->timestamps();

+ 24 - 0
database/seeders/BrigadierSeeder.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace Database\Seeders;
+
+use App\Models\Brigadier;
+use Illuminate\Database\Console\Seeds\WithoutModelEvents;
+use Illuminate\Database\Seeder;
+
+class BrigadierSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     */
+    public function run(): void
+    {
+        Brigadier::updateOrCreate(['id' => 1], ['name' => 'Не выбран']);
+        if(Brigadier::query()->get()->count() == 1) {
+            Brigadier::updateOrCreate(['name' => 'Ленин']);
+            Brigadier::updateOrCreate(['name' => 'Сталин']);
+            Brigadier::updateOrCreate(['name' => 'Брежнев']);
+            Brigadier::updateOrCreate(['name' => 'Хрущёв']);
+        }
+    }
+}