<?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 getCategory(): string
    {
        return $this->attributes['category'];
    }
    public function getPrice(): int
    {
        return $this->attributes['price'];
    }
    //추가기능
    //판매금액표시용
    public function getTitleWithPrice(array $attrs = []): string
    {
        $format = array_key_exists('format', $attrs) ? $attrs['format'] : "%s원 %s";
        return sprintf($format, number_format($this->getPrice()), $this->getTitle());
    }
}
