<?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('company_workers_timesheet', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('worker_id')->index();
            $table->decimal('rate', 10, 2)->comment = 'Hard copy of worker rate';
            $table->decimal('total_hours', 10, 2);
            $table->date('date');
            $table->time('time_in')->nullable();
            $table->time('time_out')->nullable();
            $table->text('description')->nullable();
            $table->enum('role', ['worker', 'supervisor', 'manager', 'accountant']);
            $table->text('request_modification_message')->nullable();
            $table->enum('status', ['pending', 'submitted', 'approved', 'absent', 'confirmed absent', 'request modification']);
            $table->enum('type', ['project','company_manager'])->nullable();
            $table->bigInteger  ('reference_id')->nullable();
            $table->bigInteger  ('company_id');
            $table->bigInteger('approved_by')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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