<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     * Creates the mentorship_categories table for organizing mentorship programmes.
     * Supports hierarchical categories (parent-child relationships).
     */
    public function up(): void
    {
        Schema::create('mentorship_categories', function (Blueprint $table) {
            $table->id();
            
            // Category details
            $table->string('name', 191);
            $table->string('slug', 191)->unique();
            $table->text('description')->nullable();
            
            // Hierarchical support
            $table->foreignId('parent_id')
                ->nullable()
                ->constrained('mentorship_categories')
                ->nullOnDelete()
                ->comment('Parent category for hierarchical structure');
            
            // Status and ordering
            $table->boolean('is_active')->default(true)->index();
            $table->integer('sort_order')->default(0);
            
            // SEO and display
            $table->string('icon', 100)->nullable()->comment('FontAwesome icon class');
            $table->string('color', 20)->nullable()->comment('Category color for UI');
            $table->string('image_path', 500)->nullable();
            
            // Metadata
            $table->string('meta_title', 191)->nullable();
            $table->text('meta_description')->nullable();
            
            // Timestamps and soft deletes
            $table->timestamps();
            $table->softDeletes();
            
            // Indexes
            $table->index(['is_active', 'sort_order']);
            $table->index('parent_id');
        });
    }

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