<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('providers', function (Blueprint $table) {
            $table->id();
            $table->string('document');
            $table->string('rg')->nullable();
            $table->unsignedBigInteger('user_id');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->decimal('average_rating', 2, 1)->nullable();
            $table->integer('total_services')->default(0);
            $table->date('birth_date')->nullable();
            $table->boolean('selfie_verified')->default(false);
            $table->boolean('document_verified')->default(false);
            $table->boolean('is_approved')->default(false);
            $table->decimal('daily_price_8h', 10, 2)->nullable();
            $table->decimal('daily_price_6h', 10, 2)->nullable();
            $table->decimal('daily_price_4h', 10, 2)->nullable();
            $table->decimal('daily_price_2h', 10, 2)->nullable();
            $table->unsignedBigInteger('profile_media_id')->nullable();
            $table->foreign('profile_media_id')->references('id')->on('media')->onDelete('set null');
            $table->timestamps();
            $table->softDeletes();
            
            $table->index('document');
            $table->index('user_id');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('providers');
    }
};
