trafficmonitor init...1
This commit is contained in:
parent
6746d750dd
commit
dca7d40be1
@ -15,19 +15,20 @@ abstract class CommonEntity extends Entity
|
|||||||
parent::__construct($data);
|
parent::__construct($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPK(): int|string
|
final public function getPK(): int|string
|
||||||
{
|
{
|
||||||
$field = constant("static::PK");
|
$field = constant("static::PK");
|
||||||
return $this->attributes[$field] ?? "";
|
return $this->attributes[$field] ?? "";
|
||||||
}
|
}
|
||||||
public function getTitle(): string
|
final public function getTitle(): string
|
||||||
{
|
{
|
||||||
$field = constant("static::TITLE");
|
$field = constant("static::TITLE");
|
||||||
return $this->attributes[$field] ?? "";
|
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
|
public function getStatus(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@ -15,7 +15,23 @@ class TrafficEntity extends CommonEntity
|
|||||||
protected $casts = [
|
protected $casts = [
|
||||||
// 'role' => 'json-array', // 🚫 CSV 형식 저장을 위해 제거
|
// '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
|
public function getIP(): string
|
||||||
{
|
{
|
||||||
return $this->attributes['ip'];
|
return $this->attributes['ip'];
|
||||||
|
|||||||
@ -33,7 +33,7 @@ class CollectorForm extends CommonForm
|
|||||||
switch ($field) {
|
switch ($field) {
|
||||||
case 'trafficinfo_uid':
|
case 'trafficinfo_uid':
|
||||||
foreach (service('trafficservice')->getEntities() as $entity) {
|
foreach (service('trafficservice')->getEntities() as $entity) {
|
||||||
$tempOptions[$entity->getPK()] = $entity->getTitle();
|
$tempOptions[$entity->getPK()] = $entity->getCustomTitle("%s[%s]", ['client', 'server_ip']);
|
||||||
}
|
}
|
||||||
$options['options'] = $tempOptions;
|
$options['options'] = $tempOptions;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -11,7 +11,6 @@ class AuthHelper extends CommonHelper
|
|||||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case 'id':
|
|
||||||
case 'passwd':
|
case 'passwd':
|
||||||
$form = form_password($field, "", [...$extras]);
|
$form = form_password($field, "", [...$extras]);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Helpers;
|
|
||||||
|
|
||||||
use App\Models\PaymentModel;
|
|
||||||
|
|
||||||
class HomeHelper extends CommonHelper
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user