<?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('producers', function (Blueprint $table) {
            $table->id();
            
            $table->foreignId('user_id')->constrained('users');
            $table->string('brand_name')->nullable();
            $table->string('work_email')->nullable();
            $table->string('work_phone')->nullable();
            $table->string('activity_main_category');
            $table->string('activity_sub_category')->nullable();
            $table->string('activity_product')->nullable();
            $table->integer('unit_capacity')->nullable();
            $table->decimal('unit_area', 10, 2)->nullable();
            $table->foreignId('work_province_id')->nullable()->constrained('provinces');
            $table->foreignId('work_county_id')->nullable()->constrained('counties');
            $table->text('work_address')->nullable();
            $table->string('work_postal_code')->nullable();
            $table->decimal('work_latitude', 10, 8);
            $table->decimal('work_longitude', 11, 8)->nullable();
            $table->json('business_license');
            $table->json('education_certificates')->nullable();
            $table->json('skill_certificates')->nullable() ->nullable();
            $table->json('work_experience')->nullable();
            $table->string('ownership_document')->nullable();
            $table->date('lease_start_date')->nullable();
            $table->date('lease_end_date')->nullable();
            $table->json('unit_images')->nullable();
            $table->json('unit_videos')->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('producers');
    }
};
