<?php

namespace App\Models;

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

class UserContractEvent extends Model
{
    use HasFactory;

    protected $fillable = [
        'history_contract_id', //  id of 'history_contracts_users' table
        'user_id',
        'company_id',
        'contract_id',
        'name',
        'date',
        'description',
        'created_by',
        'updated_by',
        'days_before_to_notify',
    ];

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

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

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

    public function getContractEventDaysBeforeToNotifyAttribute()
    {
        return $this->contract->contract_days_before_to_notify;
    }
}
