<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up()
    {
        Schema::create('traslados_prenda', function (Blueprint $table) {
            $table->id();
            $table->foreignId('orden_produccion_id')->constrained('orden_produccions')->onDelete('cascade');
            $table->morphs('referencia');
            $table->string('origen')->nullable();
            $table->string('destino')->nullable();
            $table->integer('cantidad_enviada')->default(0);
            $table->integer('cantidad_recibida')->nullable();
            $table->integer('prendas_defectuosas')->nullable();
            $table->integer('reparaciones')->nullable();
            $table->integer('saldos')->nullable();
            $table->integer('residual')->nullable();
            $table->timestamp('fecha_envio')->nullable();
            $table->timestamp('fecha_recepcion')->nullable();
            $table->string('estado')->default('pendiente');
            $table->foreignId('ingresado_por')->nullable()->constrained('users');
            $table->text('notas')->nullable();
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('traslados_prenda');
    }
};
