<?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::create('turnos', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->datetime('inicio');
            $table->string('correo');
            $table->string('nombrecompleto');
            $table->text('descripcion');

            $table->foreignId('cliente_id')->nullable() //puede ser que el turno se le asigne a alguien que aún no es cliente
                  ->constrained('clientes')
                  ->onDelete('cascade');

            $table->foreignId('estadoturno_id')
                  ->constrained('estadosturnos')
                  ->onDelete('cascade');

            $table->foreignId('agenda_id')
                  ->constrained('agendas')
                  ->onDelete('cascade');

            $table->foreignId('profesional_id')
                  ->constrained('profesionales')
                  ->onDelete('cascade'); 
            
            $table->foreignId('servicio_id')
                  ->constrained('servicios')
                  ->onDelete('cascade'); 

            $table->foreignId('modalidad_id')
                  ->constrained('modalidades')
                  ->onDelete('cascade'); 
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('turnos');
    }
};
