<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\WorkAreaLists;

class BorrowPendingWorkers extends Model
{
    use HasFactory;
    protected $table = 'borrow_pending_workers';
    protected $fillable = [
        'search_id',
        'borrow_request_id',
        'worker_id',
        'date_from',
        'date_to',
        'original_rate',
        'rate',
        'approver_note',
        'status',
    ];

    public function work_area_lists()
    {
        return $this->hasMany(WorkAreaLists::class, 'worker_id', 'worker_id')
            ->join('work_areas', 'work_areas.id', '=', 'work_area_lists.work_area_id')
            ->where('work_area_lists.worker_type', 'worker');
    }
}
