54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Entities;
|
|
|
|
class ProductEntity extends BaseEntity
|
|
{
|
|
protected $datamap = [];
|
|
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
|
protected $casts = [];
|
|
private $_devices = [];
|
|
|
|
//기본기능
|
|
public function getTitle(): string
|
|
{
|
|
return $this->attributes['name'];
|
|
}
|
|
public function getCategory(): string
|
|
{
|
|
return $this->attributes['category'];
|
|
}
|
|
//추가기능
|
|
//이미지관련 Field전용
|
|
final public function getFileImage($size = false, $field = "photo")
|
|
{
|
|
if (is_null($this->attributes[$field])) {
|
|
return "";
|
|
}
|
|
$files = explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field]);
|
|
return sprintf(
|
|
"<img src=\"/upload_images/%s%s\" alt=\"%s\">",
|
|
$size ? $size . '_' : '',
|
|
$files[1],
|
|
$files[0]
|
|
);
|
|
}
|
|
//판매금액표시용
|
|
public function getSalePrice(array $options = []): string
|
|
{
|
|
$price = $this->attributes['price'] - $this->attributes['sale'];
|
|
if (array_key_exists('format', $options)) {
|
|
$price = sprintf($options['format'], number_format($price));
|
|
}
|
|
return $price;
|
|
}
|
|
public function getDevices(): array
|
|
{
|
|
return $this->_devices;
|
|
}
|
|
public function setDevices(array $devices)
|
|
{
|
|
$this->_devices = $devices;
|
|
}
|
|
}
|