<?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->string('title')->nullable()->after('id');
            $table->string('first_name')->after('title');
            $table->string('last_name')->after('first_name');
            $table->string('username')->unique()->after('last_name');
            $table->date('access_start')->nullable()->after('password');
            $table->date('access_end')->nullable()->after('access_start');
            $table->string('phone')->nullable()->after('email');
            $table->text('address')->nullable()->after('phone');
            $table->boolean('is_active')->default(true)->after('address');
            $table->string('profile_photo_path')->nullable();
            
            // Eliminar campos no necesarios
            $table->dropColumn('name');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('title');
            $table->dropColumn('first_name');
            $table->dropColumn('last_name');
            $table->dropColumn('username');
            $table->dropColumn('access_start');
            $table->dropColumn('access_end');
            $table->dropColumn('phone');
            $table->dropColumn('address');
            $table->dropColumn('is_active');
            $table->dropColumn('profile_photo_path ');
            
            $table->string('name')->after('id');
        });
    }
};
