dbmsv4/app/Helpers/Customer/AccountHelper.php
2025-11-21 13:10:03 +09:00

55 lines
2.0 KiB
PHP

<?php
namespace App\Helpers\Customer;
class AccountHelper extends CustomerHelper
{
public function __construct()
{
parent::__construct();
}
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
switch ($field) {
case 'bank':
$forms = [];
array_shift($viewDatas['formOptions'][$field]['options']);
foreach ($viewDatas['formOptions'][$field]['options'] as $key => $label)
$forms[] = form_radio($field, $key, $key == $value, $extras) . $label;
$form = implode(" ", $forms);
break;
case 'role':
$currentRoles = is_array($value)
? array_map('strtolower', array_map('trim', $value))
: [];
$form = '';
//Form페이지에서는 맨앞에것 제외하기 위함
$firstOption = array_shift($viewDatas['formOptions'][$field]['options']);
foreach ($viewDatas['formOptions'][$field]['options'] as $key => $label) {
$checked = in_array(strtolower(trim($key)), $currentRoles);
$form .= '<label class="me-3">';
$form .= form_checkbox('role[]', $key, $checked, ['id' => "role_{$key}", ...$extras]);
$form .= " {$label}";
$form .= '</label>';
}
break;
default:
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
break;
}
return $form;
} //
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;
}
return $value;
}
}