<?php

namespace App\Domain\Website\Models;

use App\Domain\Recruitment\Models\JobDemand;
use App\Support\Concerns\HasUuid;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class EmployerRequisitionPosition extends Model
{
    use HasFactory, HasUuid;

    protected $guarded = ['id', 'uuid'];

    protected function casts(): array
    {
        return [
            'required_documents' => 'array',
            'overtime_available' => 'boolean',
            'accommodation_provided' => 'boolean',
            'food_provided' => 'boolean',
            'food_allowance' => 'boolean',
            'transport_provided' => 'boolean',
            'medical_provided' => 'boolean',
            'insurance_provided' => 'boolean',
            'airfare_provided' => 'boolean',
            'visa_cost_covered' => 'boolean',
            'work_permit_cost_covered' => 'boolean',
            'uniform_provided' => 'boolean',
        ];
    }

    public function requisition(): BelongsTo
    {
        return $this->belongsTo(EmployerRequisition::class, 'employer_requisition_id');
    }

    public function jobCategory(): BelongsTo
    {
        return $this->belongsTo(JobCategory::class);
    }

    public function jobDemand(): BelongsTo
    {
        return $this->belongsTo(JobDemand::class);
    }

    public function isConverted(): bool
    {
        return $this->job_demand_id !== null;
    }
}
