<?php

namespace App\Models;

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

class WorkPermit extends Model
{
    use HasFactory;

    protected $fillable = [
        'type_work_permit_id',
        'company_id',
        'user_id',
        'register_code',
        'solicitation_date',
        'start_date',
        'end_date',
        'observations',
        'status',
        'rejected_reason',
        'reviewed_by',
        'support_document',
        'status_support_document',
        'rejected_reason_support_document',
    ];

    public function user()
    {
        return $this->belongsTo('App\Models\User');
    }

    public function typeWorkPermit()
    {
        return $this->belongsTo('App\Models\TypeWorkPermit');
    }

    public function company()
    {
        return $this->belongsTo('App\Models\Company');
    }

    public function getTypeWorkPermitNameAttribute()
    {
        return $this->typeWorkPermit->name;
    }

    public function getSupportRequiredAttribute()
    {
        return $this->typeWorkPermit->support_document_required;
    }

}

