dbmsv2/app/Entities/Equipment/ServerEntity.php
2025-09-08 14:21:14 +09:00

52 lines
1.7 KiB
PHP

<?php
namespace App\Entities\Equipment;
use App\Entities\Equipment\ServerPartEntity;
use App\Models\Equipment\ServerModel;
class ServerEntity extends EquipmentEntity
{
const PK = ServerModel::PK;
const TITLE = ServerModel::TITLE;
const DEFAULT_STATUS = STATUS['AVAILABLE'];
public function addServerPartEntity(string $partType, ServerPartEntity $entity): ServerEntity
{
if (!array_key_exists('serverPartEntities', $this->attributes)) {
$this->attributes['serverPartEntities'] = [];
}
if (!array_key_exists($partType, $this->attributes['serverPartEntities'])) {
$this->attributes['serverPartEntities'][$partType] = [];
}
$this->attributes['serverPartEntities'][$partType][] = $entity;
return $this;
}
public function setServerPartEntities(string $partType, array $serverPartEntities): ServerEntity
{
if (!array_key_exists('serverPartEntities', $this->attributes)) {
$this->attributes['serverPartEntities'] = [];
}
$this->attributes['serverPartEntities'][$partType] = $serverPartEntities;
return $this;
}
public function getServerPartEntities(string $partType): array
{
if (!array_key_exists('serverPartEntities', $this->attributes)) {
return [];
}
if (!array_key_exists($partType, $this->attributes['serverPartEntities'])) {
return [];
}
return $this->attributes['serverPartEntities'][$partType];
}
//기본기능용
public function getCode(): string
{
return $this->attributes['code'];
}
public function getTitle(): string
{
return sprintf("%s[%s]", parent::getTitle(), $this->getCode());
}
}