<?php
namespace App\Entity;
use App\Entity\Product\ConfirmedProduct;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Class PriceHistory
*
* @ORM\Entity(repositoryClass="App\Repository\PriceHistoryRepository")
* @ORM\Table(name="malys_price_history")
* @ORM\HasLifecycleCallbacks()
* @package App\Entity
*/
class PriceHistory
{
public const PRICE_COLS = [
'priceT1',
'priceT2',
'priceT3',
'priceT4',
'priceTO',
'priceTM',
'priceTG',
'priceTGR',
'pricePromo'
];
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var ConfirmedProduct
*
* @ORM\ManyToOne(targetEntity="App\Entity\Product\ConfirmedProduct", inversedBy="priceHistories")
* @ORM\JoinColumn(name="product_id", referencedColumnName="id")
* @Assert\Type("App\Entity\Product\ConfirmedProduct")
*/
protected $product;
/**
* @var float
*
* @ORM\Column(name="price_tg", type="float", nullable=true)
*/
protected $priceTG;
/**
* @var float
*
* @ORM\Column(name="price_tgr", type="float", nullable=true)
* @Assert\NotBlank
*/
protected $priceTGR;
/**
* @var float
*
* @ORM\Column(name="price_t1", type="float", nullable=true)
*/
protected $priceT1;
/**
* @var float
*
* @ORM\Column(name="price_t2", type="float", nullable=true)
*/
protected $priceT2;
/**
* @var float
*
* @ORM\Column(name="price_t3", type="float", nullable=true)
*/
protected $priceT3;
/**
* @var float
*
* @ORM\Column(name="price_t4", type="float", nullable=true)
*/
protected $priceT4;
/**
* @var float
*
* @ORM\Column(name="price_tm", type="float", nullable=true)
*/
protected $priceTM;
/**
* @var float
*
* @ORM\Column(name="price_promo", type="float", nullable=true)
*/
protected $pricePromo;
/**
* @var array
*
* @ORM\Column(name="column_updated", type="array", nullable=true)
*/
protected $columnUpdated;
/**
* @var DateTime
*
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
protected $updatedAt;
/**
* PriceHistory constructor.
* @param ConfirmedProduct $product
*/
public function __construct(ConfirmedProduct $product)
{
$this->setProduct($product);
$this->setPriceT1($product->getPriceT1());
$this->setPriceT2($product->getPriceT2());
$this->setPriceT3($product->getPriceT3());
$this->setPriceT4($product->getPriceT4());
$this->setPriceTM($product->getPriceTM());
$this->setPriceTG($product->getPriceTG());
$this->setPriceTGR($product->getPriceTGR());
$this->setPricePromo($product->getPricePromo());
}
public function __toString()
{
return $this->id;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return ConfirmedProduct
*/
public function getProduct()
{
return $this->product;
}
/**
* @param ConfirmedProduct $product
*/
public function setProduct($product)
{
$this->product = $product;
}
/**
* @return float
*/
public function getPriceTG()
{
return $this->priceTG;
}
/**
* @param float $priceTG
*/
public function setPriceTG($priceTG)
{
$this->priceTG = $priceTG;
}
/**
* @return float
*/
public function getPriceTGR()
{
return $this->priceTGR;
}
/**
* @param float $priceTGR
*/
public function setPriceTGR($priceTGR)
{
$this->priceTGR = $priceTGR;
}
/**
* @return float
*/
public function getPriceT1()
{
return $this->priceT1;
}
/**
* @param float $priceT1
*/
public function setPriceT1($priceT1)
{
$this->priceT1 = $priceT1;
}
/**
* @return float
*/
public function getPriceT2()
{
return $this->priceT2;
}
/**
* @param float $priceT2
*/
public function setPriceT2($priceT2)
{
$this->priceT2 = $priceT2;
}
/**
* @return float
*/
public function getPriceT3()
{
return $this->priceT3;
}
/**
* @param float $priceT3
*/
public function setPriceT3($priceT3)
{
$this->priceT3 = $priceT3;
}
/**
* @return float
*/
public function getPriceT4()
{
return $this->priceT4;
}
/**
* @param float $priceT4
*/
public function setPriceT4($priceT4)
{
$this->priceT4 = $priceT4;
}
/**
* @return float
*/
public function getPriceTM()
{
return $this->priceTM;
}
/**
* @param float $priceTM
*/
public function setPriceTM($priceTM)
{
$this->priceTM = $priceTM;
}
/**
* @return float
*/
public function getPricePromo()
{
return $this->pricePromo;
}
/**
* @param float $pricePromo
*/
public function setPricePromo($pricePromo)
{
$this->pricePromo = $pricePromo;
}
/**
* @return array
*/
public function getColumnUpdated()
{
return $this->columnUpdated;
}
/**
* @param array $columnUpdated
*/
public function setColumnUpdated($columnUpdated)
{
$this->columnUpdated = $columnUpdated;
}
/**
* @return DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set updatedAt
*
* @return PriceHistory
* @ORM\PrePersist()
* @throws Exception
*/
public function setUpdatedAt()
{
$this->updatedAt = new DateTime();
return $this;
}
}