bt-trader init
This commit is contained in:
parent
9c354d8a32
commit
73b44dd3ee
@ -13,6 +13,7 @@ abstract class CommonEntity extends Entity
|
||||
* 이 엔티티에서 "빈문자/공백 입력은 NULL로 저장"해야 하는 필드 목록.
|
||||
* 기본은 빈 배열이고, 각 Entity에서 필요한 것만 override해서 채우면 됨.
|
||||
*/
|
||||
protected array $nullableFields = [];
|
||||
public function __construct(array|null $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
@ -33,8 +34,21 @@ abstract class CommonEntity extends Entity
|
||||
final public function __set(string $key, $value = null)
|
||||
{
|
||||
if (array_key_exists($key, $this->attributes)) {
|
||||
return $this->attributes[$key] = $value;
|
||||
|
||||
// 이 엔티티에서 NULL로 보정할 필드만 처리 (화이트리스트)
|
||||
if (!empty($this->nullableFields) && in_array($key, $this->nullableFields, true)) {
|
||||
if (is_string($value)) {
|
||||
$value = trim($value);
|
||||
}
|
||||
$this->attributes[$key] = ($value === '' || $value === null) ? null : $value;
|
||||
return;
|
||||
}
|
||||
|
||||
// 기본: 그대로 저장
|
||||
$this->attributes[$key] = $value;
|
||||
return;
|
||||
}
|
||||
|
||||
parent::__set($key, $value);
|
||||
}
|
||||
|
||||
@ -50,11 +64,6 @@ abstract class CommonEntity extends Entity
|
||||
return $this->attributes[$field] ?? "";
|
||||
}
|
||||
|
||||
public function getCustomTitle(): string
|
||||
{
|
||||
return $this->getTitle();
|
||||
}
|
||||
|
||||
final public function getStatus(): string
|
||||
{
|
||||
return $this->attributes['status'] ?? "";
|
||||
@ -74,4 +83,9 @@ abstract class CommonEntity extends Entity
|
||||
{
|
||||
return $this->attributes['deleted_at'] ?? "";
|
||||
}
|
||||
|
||||
public function getCustomTitle(): string
|
||||
{
|
||||
return $this->getTitle();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user