Alexander Musikhin пре 11 месеци
родитељ
комит
3bd8107b43

+ 10 - 0
app/Http/Controllers/ProductController.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+class ProductController extends Controller
+{
+    //
+}

+ 10 - 0
app/Http/Controllers/ProductSKUController.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+class ProductSKUController extends Controller
+{
+    //
+}

+ 12 - 0
app/Models/Product.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class Product extends Model
+{
+    use SoftDeletes;
+    protected $guarded = false;
+}

+ 13 - 0
app/Models/ProductSKU.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class ProductSKU extends Model
+{
+    use SoftDeletes;
+    protected $guarded = false;
+    public $table = 'products_sku';
+}

+ 36 - 0
database/migrations/2024_12_19_143844_create_products_table.php

@@ -0,0 +1,36 @@
+<?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::create('products', function (Blueprint $table) {
+            $table->id();
+            $table->unsignedInteger('year');
+            $table->string('name');
+            $table->string('nomenclature_number');
+            $table->string('type');
+            $table->string('article')->unique();
+            $table->string('sizes');
+            $table->string('unit');
+            // other params
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('products');
+    }
+};

+ 40 - 0
database/migrations/2024_12_19_145335_create_products_sku_table.php

@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     * Остатки продукта, каждый продукт уникален, то есть если добавили в заказ 5 одинаковых лавок,
+     * то здесь создаётся 5 записей и привязываются к заказу
+     */
+    public function up(): void
+    {
+        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->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('products_sku');
+    }
+};