dbmsv3/app/Services/Equipment/LineService.php
2025-10-16 10:45:12 +09:00

63 lines
1.5 KiB
PHP

<?php
namespace App\Services\Equipment;
use App\Entities\Equipment\LineEntity;
use App\Helpers\Equipment\LineHelper;
use App\Models\Equipment\LineModel;
use App\Services\Part\IPService;
class LineService extends EquipmentService
{
private ?IPService $_ipService = null;
public function __construct()
{
parent::__construct(new LineModel(), new LineHelper());
$this->addClassName('Line');
}
public function getFormFields(): array
{
return [
"type",
"title",
"bandwith",
"start_at",
"end_at",
"status",
];
}
public function getFormFilters(): array
{
return [
"type",
'status',
];
}
public function getBatchjobFields(): array
{
return ['status'];
}
final public function getIPService(): IPService
{
if (!$this->_ipService) {
$this->_ipService = new IPService();
}
return $this->_ipService;
}
//기본 기능부분
public function create(array $formDatas): LineEntity
{
//서버정보 생성
$entity = parent::create($formDatas);
//Prefixed IP to array 자동 등록
foreach ($this->getHelper()->cidrToIpRange($formDatas['bandwith']) as $ip) {
$this->getIPService()->create([
'lineinfo_uid' => $entity->getPK(),
'ip' => $ip,
'status' => STATUS['AVAILABLE'],
]);
}
return $entity;
}
}