<?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('resources', function (Blueprint $table) {
            $table->id();
            $table->string('title');
            $table->text('description')->nullable();
            $table->enum('type', ['guia', 'legislacao', 'faq', 'contacto', 'outro']);
            $table->enum('category', [
                'primeiros_passos', 'legal_regulatorio', 'tributacao',
                'financiamento', 'sectorial', 'outro'
            ]);
            $table->string('file_url')->nullable();
            $table->string('external_url')->nullable();
            $table->string('reference')->nullable();
            $table->integer('pages')->nullable();
            $table->integer('download_count')->default(0);
            $table->boolean('is_active')->default(true);
            $table->integer('sort_order')->default(0);
            $table->timestamps();
            $table->softDeletes();
            $table->index(['type', 'is_active']);
            $table->index(['category', 'is_active']);
        });
    }

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