<?php

namespace App\Entities\Equipment;

use App\Models\Equipment\CHASSISModel;

class CHASSISEntity extends EquipmentEntity
{
    const PK = CHASSISModel::PK;
    const TITLE = CHASSISModel::TITLE;

    public function __construct(array|null $data = null)
    {
        parent::__construct($data);
        $this->nullableFields = [
            ...$this->nullableFields,
            'cpuinfo_uid',
            'raminfo_uid',
            'diskinfo_uid',
        ];
    }
    public function getCPUInfoUid(): ?int
    {
        return $this->cpuinfo_uid;
    }
    public function getRAMInfoUid(): ?int
    {
        return $this->raminfo_uid;
    }
    public function getDISKInfoUid(): ?int
    {
        return $this->diskinfo_uid;
    }
    //기본기능    
    public function getPrice(): int
    {
        return (int) ($this->price ?? 0);
    }
    public function getStock(): int
    {
        return (int) ($this->stock ?? 0);
    }
    public function getUsed(): int
    {
        return (int) ($this->used ?? 0);
    }
    public function getAvailable(): int
    {
        return $this->getStock() - $this->getUsed();
    }
    public function getCPUCnt(): int
    {
        return (int) ($this->cpu_cnt ?? 0);
    }
    public function getRAMCnt(): int
    {
        return (int) ($this->ram_cnt ?? 0);
    }
    public function getDISKCnt(): int
    {
        return (int) ($this->disk_cnt ?? 0);
    }
}
