<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('sales_daily', function (Blueprint $table) {
            // Info pemesan
            $table->string('nama_pemesan')->nullable()->after('tipe_pembelian');
            $table->string('nomor_invoice')->nullable()->after('nama_pemesan');
            $table->string('status_bayar')->nullable()->after('nomor_invoice'); // Success, Pending, dll
            $table->string('agen_tanggal')->nullable()->after('status_bayar');  // Pusat / nama agen

            // Varian produk TOPLES - REGULER
            $table->integer('qty_toples_reguler')->default(0)->after('qty_cookies');
            $table->integer('qty_toples_reguler_2')->default(0)->after('qty_toples_reguler');
            $table->integer('qty_toples_reguler_3')->default(0)->after('qty_toples_reguler_2');
            $table->integer('qty_toples_reguler_4')->default(0)->after('qty_toples_reguler_3');

            // Varian TOPLES - MINI
            $table->integer('qty_mini_1')->default(0)->after('qty_toples_reguler_4');
            $table->integer('qty_mini_2')->default(0)->after('qty_mini_1');

            // Varian lainnya
            $table->integer('qty_kassaba')->default(0)->after('qty_mini_2');
            $table->integer('qty_daily')->default(0)->after('qty_kassaba');
            $table->integer('qty_bag')->default(0)->after('qty_daily');
            $table->integer('qty_coffee')->default(0)->after('qty_bag');
            $table->integer('qty_imlek')->default(0)->after('qty_coffee');
            $table->integer('qty_only_box')->default(0)->after('qty_imlek');
        });
    }

    public function down(): void
    {
        Schema::table('sales_daily', function (Blueprint $table) {
            $table->dropColumn([
                'nama_pemesan', 'nomor_invoice', 'status_bayar', 'agen_tanggal',
                'qty_toples_reguler', 'qty_toples_reguler_2', 'qty_toples_reguler_3', 'qty_toples_reguler_4',
                'qty_mini_1', 'qty_mini_2',
                'qty_kassaba', 'qty_daily', 'qty_bag', 'qty_coffee', 'qty_imlek', 'qty_only_box',
            ]);
        });
    }
};
