<?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('noc', function (Blueprint $table) {
                $table->id();
                $table->unsignedBigInteger('permohonan_id');
                $table->unsignedBigInteger('persetujuan_penawaran_id');
                $table->string('bukti_bayar')->nullable();
                $table->decimal('nominal_bayar', 15, 2)->nullable();
                $table->boolean('status_bayar')->default(false);
                $table->date('tanggal_pembayaran')->nullable();
                $table->decimal('nominal_penyelesaian', 15, 2)->nullable();
                $table->boolean('status_penyelesaiaan')->default(false);
                $table->date('tanggal_penyelesaian')->nullable();
                $table->string('bukti_penyelesaian')->nullable();
                $table->string('bukti_ksl')->nullable();
                $table->text('memo_penyelesaian')->nullable();
                $table->boolean('status')->default(true);
                $table->string('catatan_noc')->nullable();
                $table->char('authorized_status', 1)->nullable();
                $table->timestamp('authorized_at')->nullable();
                $table->unsignedBigInteger('authorized_by')->nullable();
                $table->unsignedBigInteger('created_by')->nullable();
                $table->unsignedBigInteger('updated_by')->nullable();
                $table->unsignedBigInteger('deleted_by')->nullable();
                $table->timestamps();
                $table->softDeletes();

                $table->foreign('permohonan_id')->references('id')->on('permohonan');
                $table->foreign('persetujuan_penawaran_id')->references('id')->on('persetujuan_penawaran');
            });
        }

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