<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\DB;


class Resource extends Model
{
    use HasFactory;
    use SoftDeletes;

    public function __construct()
    {
        setTenant();
    }

    protected $fillable = [
        'user_id',
        'first_name',
        'last_name',
        'birth_day',
        'birth_place_id',
        'fiscal_code',
        'phone',
        'email',
        'address',
        'zip',
        'city_id',
        'country_id',
        'domicile',
        'enabled',
    ];

    public function birth_place()
    {
        return $this->belongsTo(\App\Models\City::class);
    }

    public function country()
    {
        return $this->belongsTo(\App\Models\Country::class);
    }

    public function city()
    {
        return $this->belongsTo(\App\Models\City::class);
    }

    public function documents()
    {
        return $this->hasMany(\App\Models\ResourceDocument::class);
    }

    public function contracts()
    {
        return $this->hasMany(\App\Models\ResourceContract::class);
    }

    public function equipments()
    {
        return $this->hasMany(\App\Models\ResourceEquipments::class);
    }

    public function rates()
    {
        return $this->hasMany(\App\Models\ResourceRate::class);
    }

}
