<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     * Add device validation settings to companies table
     */
    public function up(): void
    {
        Schema::table('companies', function (Blueprint $table) {
            // Device validation setting
            // When enabled, attendance will validate device
            // Behavior depends on allow_editable_location:
            // - editable=true: any device allowed, but recorded device uses registered device info
            // - editable=false: must use registered device, otherwise rejected
            $table->boolean('device_validation_enabled')->default(false)->after('allow_editable_location');

            // Max devices per user (default 3)
            $table->unsignedTinyInteger('max_devices_per_user')->default(3)->after('device_validation_enabled');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('companies', function (Blueprint $table) {
            $table->dropColumn(['device_validation_enabled', 'max_devices_per_user']);
        });
    }
};
