dbmsv4/app/Helpers/Customer/Wallet/CouponHelper.php
2025-12-22 09:42:38 +09:00

55 lines
2.1 KiB
PHP

<?php
namespace App\Helpers\Customer\Wallet;
use RuntimeException;
class CouponHelper extends WalletHelper
{
public function __construct()
{
parent::__construct();
}
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
{
switch ($field) {
case 'amount':
$value = number_format($value) . "";
break;
default:
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
break;
}
if (is_array($value)) {
throw new RuntimeException(static::class . "->" . __FUNCTION__ . "에서 오류발생:{$field}에 해당하는 Return 값이 배열형식입니다.\n" . var_export($value, true));
}
return $value;
}
public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string
{
switch ($action) {
case 'modify':
//역활이 보안관리자가 아니면 수정불가
if ($this->getAuthContext()->isAccessRole([ROLE['USER']['SECURITY']])) {
$action = parent::getListButton($action, $label, $viewDatas, $extras);
} else {
$oldBatchJobUids = old("batchjob_uids", null);
$oldBatchJobUids = is_array($oldBatchJobUids) ? $oldBatchJobUids : [$oldBatchJobUids];
$action = form_checkbox([
"id" => "checkbox_uid_{$viewDatas['entity']->getPK()}",
"name" => "batchjob_uids[]",
"value" => $viewDatas['entity']->getPK(),
"class" => "batchjobuids_checkboxs",
"checked" => in_array($viewDatas['entity']->getPK(), $oldBatchJobUids)
]);
$action .= $label;
}
break;
default:
$action = parent::getListButton($action, $label, $viewDatas, $extras);
break;
}
return $action;
}
}