<?php

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

class CreatePembelianBarangTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('pembelian_barang', function (Blueprint $table) {
            $table->id();
            $table->foreignId('barang_id')->constrained('barang')->onDelete('cascade');
            $table->integer('qty');
            $table->string('satuan');
            $table->integer('total_harga');
            $table->string('satuan_susut')->nullable();
            $table->integer('harga_susut')->nullable();
            $table->date('tgl_beli');
            $table->boolean('is_cash')->default(0)->nullable();
            $table->foreignId('metode_bayar_id')->nullable()->constrained('metode_pembayaran')->onDelete('cascade');
            $table->text('catatan')->nullable();
            $table->foreignId('id_laundry')->constrained('laundry')->onDelete('cascade');
            $table->string('volume_awal')->nullable();
            $table->string('volume_akhir')->nullable();
            $table->timestamps();
        });
    }

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