dbmsv2/app/Services/Equipment/SwitchService.php
2025-09-01 18:41:54 +09:00

66 lines
1.7 KiB
PHP

<?php
namespace App\Services\Equipment;
use App\Entities\Equipment\SwitchEntity;
use App\Models\Equipment\SwitchModel;
use App\Services\Equipment\EquipmentService;
class SwitchService extends EquipmentService
{
public function __construct()
{
parent::__construct(new SwitchModel());
$this->addClassName('Switch');
}
public function getFormFields(): array
{
return [
"serverinfo_uid",
"code",
"status",
];
}
public function getFormFilters(): array
{
return [
'clientinfo_uid',
'serviceinfo_uid',
'serverinfo_uid',
'status'
];
}
public function getIndexFields(): array
{
return [
'clientinfo_uid',
'serviceinfo_uid',
'serverinfo_uid',
'status',
];
}
public function getBatchjobFields(): array
{
return ['clientinfo_uid', 'serverinfo_uid', 'status'];
}
//기본 기능부분
//FieldForm관련용
//상태변경
public function setStatus(string $code, string $status): SwitchEntity
{
//code의 경우 사용가능/사용중으로 설정작업
$entity = $this->getEntity($code);
if (!$entity) {
throw new \Exception("{$code}에 대한 Switch Port정보를 찾을수 없습니다.");
}
return $this->getModel()->modify($entity, ['status' => $status]);
}
//List 검색용
//OrderBy 처리
public function setOrderBy(mixed $field = null, mixed $value = null): void
{
$this->getModel()->orderBy('code', 'ASC');
parent::setOrderBy($field, $value);
}
}