<?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('clients', function (Blueprint $table) {
            $table->string('contact_last_name')->nullable()->after('patente');
            $table->string('contact_first_name')->nullable()->after('contact_last_name');
            $table->string('contact_job_title')->nullable()->after('contact_first_name');
            $table->string('contact_email')->nullable()->after('contact_job_title');
            $table->string('contact_phone')->nullable()->after('contact_email');
            $table->foreignId('internal_responsible_id')->nullable()->after('contact_phone')
                ->constrained('users')->nullOnDelete();
            $table->string('status')->nullable()->after('internal_responsible_id');
            $table->text('internal_notes')->nullable()->after('status');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('clients', function (Blueprint $table) {
            $table->dropForeign(['internal_responsible_id']);
            $table->dropColumn([
                'contact_last_name',
                'contact_first_name',
                'contact_job_title',
                'contact_email',
                'contact_phone',
                'internal_responsible_id',
                'status',
                'internal_notes',
            ]);
        });
    }
};
