From dca7d40be1ef2507e6c3af7358fba7111a62b041 Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Thu, 13 Nov 2025 09:15:13 +0900 Subject: [PATCH] trafficmonitor init...1 --- app/Entities/CommonEntity.php | 9 +++--- app/Entities/TrafficEntity.php | 18 ++++++++++- app/Forms/CollectorForm.php | 2 +- app/Helpers/AuthHelper.php | 1 - app/Helpers/HomeHelper.php | 55 ---------------------------------- 5 files changed, 23 insertions(+), 62 deletions(-) delete mode 100644 app/Helpers/HomeHelper.php diff --git a/app/Entities/CommonEntity.php b/app/Entities/CommonEntity.php index c150685..7605c97 100644 --- a/app/Entities/CommonEntity.php +++ b/app/Entities/CommonEntity.php @@ -15,19 +15,20 @@ abstract class CommonEntity extends Entity parent::__construct($data); } - public function getPK(): int|string + final public function getPK(): int|string { $field = constant("static::PK"); return $this->attributes[$field] ?? ""; } - public function getTitle(): string + final public function getTitle(): string { $field = constant("static::TITLE"); return $this->attributes[$field] ?? ""; } - public function getCustomTitle(mixed $title = null): string + final public function getCustomTitle(string $format, array $fields): string { - return $title ? $title : $this->getTitle(); + $parameters = array_map(fn($field) => $this->attributes[$field], $fields); + return sprintf($format, ...$parameters); } public function getStatus(): string { diff --git a/app/Entities/TrafficEntity.php b/app/Entities/TrafficEntity.php index 7e722bb..afc0e9a 100644 --- a/app/Entities/TrafficEntity.php +++ b/app/Entities/TrafficEntity.php @@ -15,7 +15,23 @@ class TrafficEntity extends CommonEntity protected $casts = [ // 'role' => 'json-array', // 🚫 CSV ν˜•μ‹ μ €μž₯을 μœ„ν•΄ 제거 ]; - + public function getClient(): string + { + return $this->attributes['client']; + } + public function getSwitch(): string + { + return $this->attributes['swtich']; + } + public function getServer(): string + { + return $this->attributes['server']; + } + public function getServerIP(): string + { + return $this->attributes['server_ip']; + } + //SwitchIP public function getIP(): string { return $this->attributes['ip']; diff --git a/app/Forms/CollectorForm.php b/app/Forms/CollectorForm.php index 4e53cc1..3790a4e 100644 --- a/app/Forms/CollectorForm.php +++ b/app/Forms/CollectorForm.php @@ -33,7 +33,7 @@ class CollectorForm extends CommonForm switch ($field) { case 'trafficinfo_uid': foreach (service('trafficservice')->getEntities() as $entity) { - $tempOptions[$entity->getPK()] = $entity->getTitle(); + $tempOptions[$entity->getPK()] = $entity->getCustomTitle("%s[%s]", ['client', 'server_ip']); } $options['options'] = $tempOptions; break; diff --git a/app/Helpers/AuthHelper.php b/app/Helpers/AuthHelper.php index e12d62d..7b0216a 100644 --- a/app/Helpers/AuthHelper.php +++ b/app/Helpers/AuthHelper.php @@ -11,7 +11,6 @@ class AuthHelper extends CommonHelper public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string { switch ($field) { - case 'id': case 'passwd': $form = form_password($field, "", [...$extras]); break; diff --git a/app/Helpers/HomeHelper.php b/app/Helpers/HomeHelper.php deleted file mode 100644 index 18e5f74..0000000 --- a/app/Helpers/HomeHelper.php +++ /dev/null @@ -1,55 +0,0 @@ -setTitleField(field: PaymentModel::TITLE); - } - - public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null - { - switch ($field) { - case 'type': - $value = $viewDatas['formOptions'][$field][$value]; - break; - case 'amount': - $value = number_format($value) . "원"; - break; - default: - $value = parent::getFieldView($field, $value, $viewDatas, $extras); - break; - } - if (is_array($value)) { - throw new \Exception(__METHOD__ . "μ—μ„œ 였λ₯˜: {$field}의 값이 Arrayν˜•νƒœμž…λ‹ˆλ‹€"); - } - return $value; - } - public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string - { - switch ($action) { - case 'new_service_view': - $action = form_label( - $label ? $label : ICONS['SEARCH'], - $action, - [ - "data-src" => '/admin/customer/service/view/' . $viewDatas['entity']->getPK(), - "data-bs-toggle" => "modal", - "data-bs-target" => "#modal_action_form", - "class" => "btn btn-sm form-label-sm", - ...$extras, - ] - ); - break; - default: - $action = parent::getListButton($action, $label, $viewDatas, $extras); - break; - } - return $action; - } -}