shoppingmallv2/app/Entities/BaseEntity.php
최준흠git config git config --helpgit config --global user.name 최준흠 cd4398a4f8 shoppingmallv2 init..
2023-08-07 23:09:46 +09:00

38 lines
1022 B
PHP

<?php
namespace App\Entities;
use CodeIgniter\Entity\Entity;
abstract class BaseEntity extends Entity
{
abstract public function getPrimaryKey();
abstract public function getTitle(): string;
//조화수관련 Field전용
final public function getViews($field = 'view_cnt')
{
return $this->attributes[$field];
}
//파일관련 Field전용
final public function getFileDownload($field = "upload_file")
{
return anchor(
current_url() . "/download/{$field}/{$this->getPrimaryKey()}",
ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field])[1],
["target" => "_self"]
);
}
//이미지관련 Field전용
final public function getFileImage($field = "photo", $size = false)
{
return sprintf(
"<img src=\"/upload_images/%s%s\">",
$size ? $size . '_' : '',
explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field])[1]
);
}
}