<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('project_workers_timesheet', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('project_worker_id')->index();
            $table->bigInteger('worker_id')->index();
            $table->enum('worker_type', ['borrowed', 'inhouse']);
            $table->decimal('rate', 10, 2)->comment = 'Hard copy of worker rate';
            $table->decimal('total_billing_per_day', 10, 2)->comment = 'Outstanding pay for the day';
            $table->decimal('total_hours', 10, 2);
            $table->date('date');
            $table->time('time_in');
            $table->time('time_out');
            $table->enum('status', ['pending', 'submitted', 'approved', 'absent', 'confirmed absent', 'request modification']);
            $table->text('request_modification_message')->nullable();
            $table->string('requested_by', 150)->nullable();
            $table->string('approved_by', 150)->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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