56 lines
1.8 KiB
PHP
56 lines
1.8 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 getCustomTitle(): string
|
|
{
|
|
return sprintf("[%s] %s", $this->getCode(), $this->getTitle());
|
|
}
|
|
public function getPrice(): int
|
|
{
|
|
return $this->attributes['price'];
|
|
}
|
|
}
|