<?php

namespace App\Models;

use App\Models\Company; 
use App\Models\Worker; 
use App\Models\WorkerRequest;

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

class WorkerRequestApplication extends Model
{
	//** Traits */
    use HasFactory;

	//** Variables */

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

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

	/**
	 * Define attributes that are mass assignable. 
	 * 
	 * @var array 
	 */
    protected $fillable = 
	[
        'worker_request_id', 
        'company_id',
        'worker_id', 
        'status',
    ];

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

	//** Accessors & Mutators */

	//...

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

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

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

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