<?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('users', function (Blueprint $table) {
            $table->enum('role', [
                'admin', 
                'service_supervisor', 
                'service_coordinator', 
                'service_advisor', 
                'parts_manager', 
                'technician', 
                'quality_inspector',
                'customer_service',
                'manager'
            ])->default('technician')->after('email_verified_at');
            $table->string('branch_code', 10)->default('ACC')->after('role');
            $table->string('employee_id', 50)->unique()->nullable()->after('branch_code');
            $table->string('department', 100)->nullable()->after('employee_id');
            $table->string('phone', 20)->nullable()->after('department');
            $table->string('emergency_contact', 255)->nullable()->after('phone');
            $table->date('hire_date')->nullable()->after('emergency_contact');
            $table->enum('status', ['active', 'inactive', 'terminated', 'on_leave'])->default('active')->after('hire_date');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn([
                'role',
                'branch_code',
                'employee_id',
                'department',
                'phone',
                'emergency_contact',
                'hire_date',
                'status'
            ]);
        });
    }
};
