<?php

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

class CreateFormDaily45Table extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('form_daily_4_5', 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('tanaman'); 
            $table->string('lokasi_keluasan'); 
            $table->string('nama_dagangan_bahan_aktif'); 
            $table->string('bil_perosak_peratusan_kerosakan');
            $table->integer('no_LRMP');
            $table->string('harga');
            $table->string('kuantiti_pembelian_kadar_penggunaan');
            $table->string('Justifikasi_penggunaan');
            $table->string('alat_digunakan');
            $table->string('PHI_hari');
            $table->string('REI_hari');
            $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_5');
    }
}