<?php

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

return new class extends Migration
{
    public function up()
    {
        Schema::create('notices', function (Blueprint $table) {
            $table->id();
            $table->string('title');
            $table->text('content');
            $table->enum('notice_type', ['general', 'meeting', 'event', 'announcement', 'financial'])->default('general');
            $table->enum('target_audience', ['all', 'members', 'committee', 'specific'])->default('all');
            $table->date('publish_date')->nullable();
            $table->date('expiry_date')->nullable();
            $table->string('attachment')->nullable();
            $table->boolean('is_important')->default(false);
            $table->boolean('send_notification')->default(false);
            $table->boolean('pin_to_top')->default(false);
            $table->boolean('require_acknowledgment')->default(false);
            $table->json('specific_members')->nullable();
            $table->foreignId('created_by')->constrained('users');
            $table->enum('status', ['draft', 'published', 'archived', 'expired'])->default('published');
            $table->integer('views')->default(0);
            $table->timestamps();
            
            // সূচক (Index)
            $table->index('notice_type');
            $table->index('target_audience');
            $table->index('status');
            $table->index('created_by');
        });
    }

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