<?php

namespace App\Entities;

use App\Entities\Trait\HierarchyTrait;

class CategoryEntity extends BaseHierarchyEntity
{
    protected $datamap = [];
    protected $dates   = ['created_at', 'updated_at', 'deleted_at'];
    protected $casts   = [];

    //기본기능
    public function getPrimaryKey()
    {
        return $this->attributes['uid'];
    }
    public function getTitle(): string
    {
        return $this->attributes['name'];
    }
    public function getStatus(): string
    {
        return $this->attributes['status'];
    }

    //추가기능
    public function getHead()
    {
        return $this->attributes['head'];
    }
    public function getTail()
    {
        return $this->attributes['tail'];
    }
    public function getRole($field = 'isaccess')
    {
        return array_key_exists(
            $field,
            $this->attributes
        ) ? $this->attributes[$field] : DEFAULTS['ROLE'];
    }
}
