<?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::table('customer_profiles', function (Blueprint $table) {
            $table->string('job_title')->nullable()->after('city');
            $table->string('department')->nullable()->after('job_title');
            $table->foreignId('manager_id')->nullable()->after('department')->constrained('users')->nullOnDelete();
            $table->date('joining_date')->nullable()->after('manager_id');
            $table->string('emergency_contact_name')->nullable()->after('joining_date');
            $table->string('emergency_contact_phone')->nullable()->after('emergency_contact_name');
            $table->string('id_card_path')->nullable()->after('emergency_contact_phone');
            $table->string('contract_path')->nullable()->after('id_card_path');
            $table->string('tax_form_path')->nullable()->after('contract_path');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('customer_profiles', function (Blueprint $table) {
            $table->dropForeign(['manager_id']);
            $table->dropColumn([
                'job_title',
                'department',
                'manager_id',
                'joining_date',
                'emergency_contact_name',
                'emergency_contact_phone',
                'id_card_path',
                'contract_path',
                'tax_form_path',
            ]);
        });
    }
};
