<?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('employees', function (Blueprint $table) {
            // Device Access Settings
            $table->string('device_access_role')->nullable();
            $table->integer('device_privilege')->nullable(); // 14 admin, 0 user

            // Attendance Settings
            $table->foreignId('default_shift_id')->nullable()->constrained('shifts')->nullOnDelete();
            $table->integer('grace_period_override')->nullable();

            // App Settings
            $table->string('app_language')->nullable();
            $table->boolean('notifications_enabled')->default(true);

            // Payroll Settings
            $table->string('bank_name')->nullable();
            $table->string('bank_account')->nullable();
            $table->string('iban')->nullable();
            $table->string('pay_grade')->nullable();

            // Leave Group
            $table->foreignId('leave_group_id')->nullable()->constrained('leave_groups')->nullOnDelete();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('employees', function (Blueprint $table) {
            $table->dropConstrainedForeignId('default_shift_id');
            $table->dropConstrainedForeignId('leave_group_id');
            $table->dropColumn([
                'device_access_role',
                'device_privilege',
                'grace_period_override',
                'app_language',
                'notifications_enabled',
                'bank_name',
                'bank_account',
                'iban',
                'pay_grade',
            ]);
        });
    }
};
