58 lines
1.9 KiB
PHP
58 lines
1.9 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['AVAIABLE'];
|
|
public function addServerPartEntity(string $partType, ServerPartEntity $entity): void
|
|
{
|
|
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;
|
|
}
|
|
public function setServerPartEntities(string $partType, array $serverPartEntities): void
|
|
{
|
|
if (!array_key_exists('serverPartEntities', $this->attributes)) {
|
|
$this->attributes['serverPartEntities'] = [];
|
|
}
|
|
$this->attributes['serverPartEntities'][$partType] = $serverPartEntities;
|
|
}
|
|
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());
|
|
}
|
|
public function getClientInfoUID(): int|null
|
|
{
|
|
return $this->attributes['clientinfo_uid'] ?? null;
|
|
}
|
|
public function getServiceInfoUID(): int|null
|
|
{
|
|
return $this->attributes['serviceinfo_uid'] ?? null;
|
|
}
|
|
}
|