<?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('detail_pesanans', function (Blueprint $table) {
            $table->id();
            $table->foreignId('pesanan_id')->nullable()->references('id')->on('pesanans')->onUpdate('cascade')->onDelete('cascade');
            $table->foreignId('produk_id')->nullable()->references('id')->on('produks')->onUpdate('cascade')->onDelete('cascade');
            $table->string('nama_produk')->nullable();
            $table->string('harga_produk')->nullable();
            $table->string('jumlah_produk')->nullable();
            $table->string('total_harga_produk')->nullable();
            $table->string('keterangan_produk')->nullable();
            // diskon
            $table->foreignId('diskon_id')->nullable()->references('id')->on('diskons')->onUpdate('cascade')->onDelete('cascade');
            $table->string('nama_diskon')->nullable();
            $table->string('kode_diskon')->nullable();
            $table->string('diskon_persen')->nullable();
            $table->string('diskon_rupiah')->nullable();

            $table->unsignedBigInteger("updated_by")->nullable();
            $table->unsignedBigInteger("created_by")->nullable();
            $table->unsignedBigInteger("deleted_by")->nullable();
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('detail_pesanans');
    }
};
