<?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('vendors', function (Blueprint $table) {
            $table->string('gst_treatment')->nullable()->after('gstin');
            $table->string('pan', 10)->nullable()->after('gst_treatment');
            $table->string('tan', 20)->nullable()->after('pan');
            $table->string('vat', 50)->nullable()->after('tan');
            $table->string('website')->nullable()->after('vat');
            $table->string('vendor_code', 50)->nullable()->after('website');
            $table->string('currency', 10)->default('INR')->after('vendor_code');
            $table->boolean('also_use_as_client')->default(false)->after('currency');
            $table->boolean('use_for_dispatch')->default(false)->after('also_use_as_client');
            $table->string('contact_phone', 20)->nullable()->after('contact_person');
            $table->string('contact_email')->nullable()->after('contact_phone');
            $table->string('billing_address_line1')->nullable()->after('address');
            $table->string('billing_address_line2')->nullable()->after('billing_address_line1');
            $table->boolean('ship_to_my_address')->default(true)->after('country');
            $table->boolean('ship_to_different_address')->default(false)->after('ship_to_my_address');
            $table->string('shipping_address_line1')->nullable()->after('ship_to_different_address');
            $table->string('shipping_address_line2')->nullable()->after('shipping_address_line1');
            $table->string('shipping_city', 100)->nullable()->after('shipping_address_line2');
            $table->string('shipping_state', 100)->nullable()->after('shipping_city');
            $table->string('shipping_pincode', 10)->nullable()->after('shipping_state');
            $table->string('shipping_country', 100)->nullable()->after('shipping_pincode');
            $table->text('notes')->nullable()->after('balance_type');
            $table->text('other_info')->nullable()->after('notes');
            $table->json('additional_contacts')->nullable()->after('other_info');
        });
    }

    public function down(): void
    {
        Schema::table('vendors', function (Blueprint $table) {
            $table->dropColumn([
                'gst_treatment', 'pan', 'tan', 'vat', 'website', 'vendor_code', 'currency',
                'also_use_as_client', 'use_for_dispatch', 'contact_phone', 'contact_email',
                'billing_address_line1', 'billing_address_line2', 'ship_to_my_address',
                'ship_to_different_address', 'shipping_address_line1', 'shipping_address_line2',
                'shipping_city', 'shipping_state', 'shipping_pincode', 'shipping_country',
                'notes', 'other_info', 'additional_contacts',
            ]);
        });
    }
};
