<?php

namespace App\Models;
use App\Enums\RecordStatusEnum;
use App\Models\Traits\HasLocalizedName;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Support\Facades\Session;
use App\Traits\AuditLogTrait;

class Equipment extends BaseModel
{
    public $timestamps = false;
    use HasFactory;
    use HasLocalizedName;
    use AuditLogTrait;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'equipments';

    protected $appends = ['name'];

    protected $primaryKey = 'id';



    protected $fillable = [
        'code', 'room_id', 'name_en','capacity', 'model', 'serial_number', 'organization_id',
        'equipment_type_concept_id', 'min_temperature', 'max_temperature', 'status', 'installed_date',
        BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD,
        BaseModel::DELETED_AT_FIELD, BaseModel::DELETED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD
    ];

    public static function boot()
    {
        parent::boot();
    }

    public function type(){
        return $this->belongsTo(Concept::class, 'equipment_type_concept_id', 'id');
    }

    public function room(){
        return $this->belongsTo(Room::class, 'room_id', 'id');
    }

    public function racks(){
        return $this->hasMany(Rack::class, 'equipment_id', 'id');
    }

}
