<?php

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

class CreateFormDaily48Table extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('form_daily_4_8', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('id_farm_section'); // Foreign key to the farm section
            $table->unsignedBigInteger('created_by'); // Foreign key to the user who created the entry
            $table->string('nama_pekerja'); // Worker name
            $table->date('tarikh_lahir'); // Date of birth
            $table->string('no_kad_pengenalan'); // Identification number
            $table->string('jantina'); // Gender
            $table->string('negara_asal'); // Country of origin
            $table->json('rekod_latihan')->nullable(); // Training records, stored as JSON
            $table->json('rekod_kesihatan')->nullable(); // Health records, stored as JSON
            $table->string('nama_operator'); // Nama operator
            $table->timestamps();

            // Foreign key constraints can be added as necessary
            $table->foreign('id_farm_section')->references('id')->on('farm_section')->onDelete('cascade');
            $table->foreign('created_by')->references('id')->on('login')->onDelete('cascade');
        });
    }

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