dbmsv4/app/DTOs/Customer/ClientDTO.php
2025-11-20 11:26:53 +09:00

45 lines
1.2 KiB
PHP

<?php
namespace App\DTOs\Customer;
use App\DTOs\CommonDTO;
class ClientDTO extends CommonDTO
{
public ?int $uid = null;
public ?int $user_uid = null;
public ?string $site = null;
public ?string $role = null;
public ?string $name = null;
public ?string $phone = null;
public ?string $email = null;
public ?string $history = null;
public ?int $account_balance = null;
public ?int $coupon_balance = null;
public ?int $point_balance = null;
public ?string $status = null;
public function __construct(array $datas = [])
{
parent::__construct();
foreach ($datas as $key => $value) {
if (property_exists($this, $key)) {
if ($key === 'role' && is_array($value)) {
// 배열일 경우, 쉼표로 구분된 문자열로 변환하여 저장
$this->role = implode(DEFAULTS["DELIMITER_ROLE"], $value);
} else {
$this->{$key} = $value;
}
}
}
}
public function __get(string $name)
{
// 'role' 속성을 요청했을 때만 특별히 처리
if ($name === 'role' && is_string($this->role)) {
return explode(DEFAULTS["DELIMITER_ROLE"], $this->role);
}
return parent::__get($name);
}
}