90 lines
2.4 KiB
PHP
90 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Part;
|
|
|
|
use App\Helpers\Part\SwitchHelper;
|
|
use App\Models\Part\SwitchModel;
|
|
use App\Services\Customer\ServiceService;
|
|
use App\Services\Equipment\ServerService;
|
|
use App\Services\Part\PartService;
|
|
|
|
class SwitchService extends PartService
|
|
{
|
|
private ?ServiceService $_serviceService = null;
|
|
private ?ServerService $_serverService = null;
|
|
public function __construct()
|
|
{
|
|
parent::__construct(new SwitchModel(), new SwitchHelper());
|
|
$this->addClassName('Switch');
|
|
}
|
|
public function getFormFields(): array
|
|
{
|
|
return [
|
|
"code",
|
|
"price",
|
|
"status",
|
|
];
|
|
}
|
|
public function getFormFilters(): array
|
|
{
|
|
return [
|
|
'clientinfo_uid',
|
|
'serviceinfo_uid',
|
|
'serverinfo_uid',
|
|
'status'
|
|
];
|
|
}
|
|
public function getIndexFields(): array
|
|
{
|
|
return [
|
|
'clientinfo_uid',
|
|
'serviceinfo_uid',
|
|
'serverinfo_uid',
|
|
"price",
|
|
'status',
|
|
];
|
|
}
|
|
public function getBatchjobFields(): array
|
|
{
|
|
return ['clientinfo_uid', 'serverinfo_uid', 'status'];
|
|
}
|
|
public function getServiceService(): ServiceService
|
|
{
|
|
if (!$this->_serviceService) {
|
|
$this->_serviceService = new ServiceService();
|
|
}
|
|
return $this->_serviceService;
|
|
}
|
|
public function getServerService(): ServerService
|
|
{
|
|
if (!$this->_serverService) {
|
|
$this->_serverService = new ServerService();
|
|
}
|
|
return $this->_serverService;
|
|
}
|
|
//기본 기능부분
|
|
public function getFormOption(string $field, array $options = []): array
|
|
{
|
|
switch ($field) {
|
|
case 'serviceinfo_uid':
|
|
$options = $this->getServiceService()->getEntities();
|
|
break;
|
|
case 'serverinfo_uid':
|
|
$options = $this->getServerService()->getEntities();
|
|
break;
|
|
default:
|
|
$options = parent::getFormOption($field, $options);
|
|
break;
|
|
}
|
|
return $options;
|
|
}
|
|
//FieldForm관련용
|
|
//List 검색용
|
|
//OrderBy 처리
|
|
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
|
{
|
|
$this->getModel()->orderBy('code', 'ASC');
|
|
parent::setOrderBy($field, $value);
|
|
}
|
|
}
|