55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Entities;
|
|
|
|
use CodeIgniter\Entity\Entity;
|
|
|
|
abstract class CommonEntity extends Entity
|
|
{
|
|
protected $datamap = [];
|
|
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
|
//사용법 : $client->created_at->format('Y-m-d')
|
|
//비교방법 : if ($client->created_at < new \DateTime('2024-01-01')) {
|
|
public function __construct(array|null $data = null)
|
|
{
|
|
parent::__construct($data);
|
|
}
|
|
public function __get(string $key)
|
|
{
|
|
if (array_key_exists($key, $this->attributes)) {
|
|
return $this->attributes[$key];
|
|
}
|
|
return parent::__get($key);
|
|
}
|
|
final public function getPK(): int|string
|
|
{
|
|
$field = constant("static::PK");
|
|
return $this->attributes[$field] ?? "";
|
|
}
|
|
final public function getTitle(): string
|
|
{
|
|
$field = constant("static::TITLE");
|
|
return $this->attributes[$field] ?? "";
|
|
}
|
|
public function getCustomTitle(): string
|
|
{
|
|
return $this->getTitle();
|
|
}
|
|
final public function getStatus(): string
|
|
{
|
|
return $this->status ?? "";
|
|
}
|
|
final public function getUpdatedAt(): string
|
|
{
|
|
return $this->updated_at ?? "";
|
|
}
|
|
final public function getCreatedAt(): string
|
|
{
|
|
return $this->created_at ?? "";
|
|
}
|
|
final public function getDeletedAt(): string
|
|
{
|
|
return $this->deleted_at ?? "";
|
|
}
|
|
}
|