32 lines
759 B
PHP
32 lines
759 B
PHP
<?php
|
|
|
|
namespace App\Entities;
|
|
|
|
class DeviceEntity extends BaseEntity
|
|
{
|
|
protected $datamap = [];
|
|
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
|
protected $casts = [];
|
|
|
|
//기본기능
|
|
public function getTitle(): string
|
|
{
|
|
return $this->attributes['name'];
|
|
}
|
|
//추가기능
|
|
public function getType(): string
|
|
{
|
|
return $this->attributes['type'];
|
|
}
|
|
|
|
//판매금액표시용
|
|
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;
|
|
}
|
|
}
|