<?php

namespace App\Models;

use App\Models\Projects; 

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

class CompanyWorkerTimesheet extends Model
{
    //** Traits */
    use HasFactory;
    use SoftDeletes;

    //** Variables */

    /**
     * Manually Define Table Name.  
     * 
     * @var string 
     */
    protected $table = 'company_workers_timesheet';

    /**
     * Define Relationships that must always be loaded. 
     * 
     * @var array 
     */
    protected $with =
    [
        //...
    ];

    /**
     * Define attributes that are mass assignable. 
     * 
     * @var array 
     */
    protected $fillable =
    [
        'worker_id',
        'rate',
        'total_hours',
        'date',
        'time_in',
        'time_out',
        'reference_id',
        'request_modification_message',
        'company_id',
        'status',
        'role',
        'type',
        'description',
        'approved_by',
    ];

    /**
     * Define attributes that should be hidden for arrays. 
     * 
     * @var array 
     */
    protected $hidden =
    [
        //...
    ];

    //** Accessors & Mutators */

    //...

    //** belongsTo, belongsToMany, hasOne, hasMany relationships */ 

    /**
     * Fetch Project belongsTo relationship. 
     * 
     * // @return ? 
     */
    public function project() // : ? 
    {
        return $this->belongsTo(
            related   : Projects:: class,
            foreignKey: "reference_id",
            ownerKey  : "id",
            relation  : "project"
        );
    }
}
