51 lines
1.7 KiB
PHP
51 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Helpers;
|
|
|
|
use App\Entities\TrafficEntity;
|
|
|
|
class TrafficHelper extends CommonHelper
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
|
{
|
|
switch ($field) {
|
|
case 'server_ip':
|
|
$value = "<a href=\"admin/collector?trafficinfo_uid={$viewDatas['entity']->getPK()}\">{$value}</a>";
|
|
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 'dashboard':
|
|
$action = form_label(
|
|
$label,
|
|
$action,
|
|
[
|
|
"data-src" => current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK() . '?' . $viewDatas['uri']->getQuery(),
|
|
"data-bs-toggle" => "modal",
|
|
"data-bs-target" => "#modal_action_form",
|
|
"class" => "btn btn-sm btn-primary form-label-sm",
|
|
...$extras
|
|
]
|
|
);
|
|
break;
|
|
default:
|
|
$action = parent::getListButton($action, $label, $viewDatas, $extras);
|
|
break;
|
|
}
|
|
return $action;
|
|
}
|
|
}
|