<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('reports', function (Blueprint $table) {
            $table->id();

            $table->foreignId('user_id')->nullable()->constrained('users');
            $table->foreignId('product_id')->nullable()->constrained('products');
            $table->smallInteger('type'); // 1- growth , 2- health , 3- ration
            $table->string('title');
            $table->string('period')->nullable(); // دوره گزارش
            $table->date('date');
            $table->json('metrics')->nullable(); // متریک‌های رشد
            $table->json('data')->nullable(); // داده‌های گزارش
            $table->json('attachments')->nullable();            
            $table->enum('status', ['draft', 'published', 'archived'])->default('draft');
            $table->text('desc')->nullable();

            $table->foreignId('created_by')->constrained('users');
            $table->foreignId('updated_by')->nullable()->constrained('users');
            $table->softDeletes();
            $table->timestamps();
        });
    }

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