<?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('website_news', function (Blueprint $table) {
            $table->id();
            $table->uuid('uuid')->unique();
            $table->foreignId('academy_id')->constrained('academies');
            $table->string('title');
            $table->string('title_en')->nullable();
            $table->string('slug');
            $table->text('body');
            $table->text('body_en')->nullable();
            $table->string('excerpt')->nullable();
            $table->string('excerpt_en')->nullable();
            $table->timestamp('published_at')->nullable();
            $table->boolean('is_featured')->default(false);
            $table->unsignedSmallInteger('sort_order')->default(0);
            $table->foreignId('created_by')->constrained('users');
            $table->timestamps();
            $table->softDeletes();

            $table->unique(['academy_id', 'slug']);
            $table->index(['academy_id', 'published_at']);
        });
    }

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