<?php

namespace app\common\repositories\store\product;

use app\common\repositories\BaseRepository;
use app\common\dao\store\product\ProductAttrValueChangeLogDao;
use app\entity\data\store\StoreProductAttrValueChangeLogEntity;

class ProductAttrValueChangeLogRepository extends BaseRepository
{

    protected $dao;

    /**
     * ProductAttrValueChangeLogRepository constructor.
     * @param ProductAttrValueChangeLogDao $dao
     */
    public function __construct(ProductAttrValueChangeLogDao $dao)
    {
        $this->dao = $dao;
    }

    public function create($data)
    {
        return $this->dao->create($data);
    }

    /**
     * @param StoreProductAttrValueChangeLogEntity $storeProductAttrValueChangeLogEntity
     * @return StoreProductAttrValueChangeLogEntity
     */
    public function createByEntity(StoreProductAttrValueChangeLogEntity $storeProductAttrValueChangeLogEntity): StoreProductAttrValueChangeLogEntity
    {
        $result = $this->create($storeProductAttrValueChangeLogEntity->toUnderlineArray())->toArray();
        /** @var StoreProductAttrValueChangeLogEntity $entity */
        $entity = StoreProductAttrValueChangeLogEntity::newInstance($result);
        return $entity;
    }
}
