src/Entity/Variant.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Entity(repositoryClass="App\Repository\VariantRepository")
  8. * @ORM\EntityListeners({"App\Listener\EntityListener"})
  9. */
  10. class Variant
  11. {
  12. /**
  13. * @ORM\Id()
  14. * @ORM\GeneratedValue()
  15. * @ORM\Column(type="integer")
  16. */
  17. private $id;
  18. /**
  19. * @ORM\Column(type="string", length=150)
  20. */
  21. private $name;
  22. /**
  23. * @ORM\Column(type="string", length=20, nullable=true)
  24. */
  25. private $ean;
  26. /**
  27. * @ORM\Column(type="string", length=100, nullable=true)
  28. */
  29. private $code;
  30. /**
  31. * @ORM\Column(type="string", length=150, nullable=true, unique=true)
  32. */
  33. private $pairedCode;
  34. /**
  35. * @ORM\Column(type="boolean")
  36. */
  37. private $isActive = true;
  38. /**
  39. * @ORM\Column(type="integer", nullable=true)
  40. */
  41. private $orderBy;
  42. /**
  43. * @ORM\ManyToOne(targetEntity="App\Entity\Product", inversedBy="variants")
  44. * @ORM\JoinColumn(nullable=false)
  45. */
  46. private $product;
  47. /**
  48. * @ORM\Column(type="datetime")
  49. */
  50. private $createts;
  51. /**
  52. * @ORM\ManyToOne(targetEntity="App\Entity\User")
  53. * @ORM\JoinColumn(nullable=false)
  54. */
  55. private $createUser;
  56. /**
  57. * @ORM\OneToMany(targetEntity="App\Entity\Pricelist", mappedBy="variant", cascade={"persist", "remove"}, orphanRemoval=true, indexBy="currency")
  58. */
  59. private $pricelists;
  60. /**
  61. * @ORM\OneToMany(targetEntity="App\Entity\OrderItem", mappedBy="variant")
  62. */
  63. private $orderItems;
  64. public function __construct()
  65. {
  66. $this->pricelists = new ArrayCollection();
  67. $this->orderItems = new ArrayCollection();
  68. }
  69. public function completeName( )
  70. {
  71. return $this->getProduct()->getName();
  72. }
  73. public function getId(): ?int
  74. {
  75. return $this->id;
  76. }
  77. public function getName(): ?string
  78. {
  79. return $this->name;
  80. }
  81. public function setName(string $name): self
  82. {
  83. $this->name = $name;
  84. return $this;
  85. }
  86. public function getEan(): ?string
  87. {
  88. return $this->ean;
  89. }
  90. public function setEan(?string $ean): self
  91. {
  92. $this->ean = $ean;
  93. return $this;
  94. }
  95. public function getCode(): ?string
  96. {
  97. return $this->code;
  98. }
  99. public function setCode(?string $code): self
  100. {
  101. $this->code = $code;
  102. return $this;
  103. }
  104. public function getProduct(): Product
  105. {
  106. return $this->product;
  107. }
  108. public function setProduct(?Product $product): self
  109. {
  110. $this->product = $product;
  111. return $this;
  112. }
  113. /**
  114. * Get OrderBy
  115. *
  116. * @return mixed
  117. */
  118. public function getOrderBy()
  119. {
  120. return $this->orderBy;
  121. }
  122. /**
  123. * Set OrderBy
  124. *
  125. * @param mixed $orderBy
  126. */
  127. public function setOrderBy( $orderBy )
  128. {
  129. $this->orderBy = $orderBy;
  130. }
  131. public function getCreatets(): ?\DateTimeInterface
  132. {
  133. return $this->createts;
  134. }
  135. public function setCreatets(\DateTimeInterface $createts): self
  136. {
  137. $this->createts = $createts;
  138. return $this;
  139. }
  140. public function getCreateUser(): ?User
  141. {
  142. return $this->createUser;
  143. }
  144. public function setCreateUser(?User $createUser): self
  145. {
  146. $this->createUser = $createUser;
  147. return $this;
  148. }
  149. public function getEditts(): ?\DateTimeInterface
  150. {
  151. return $this->editts;
  152. }
  153. public function setEditts(?\DateTimeInterface $editts): self
  154. {
  155. $this->editts = $editts;
  156. return $this;
  157. }
  158. public function getEditUser(): ?User
  159. {
  160. return $this->editUser;
  161. }
  162. public function setEditUser(?User $editUser): self
  163. {
  164. $this->editUser = $editUser;
  165. return $this;
  166. }
  167. public function getIsActive(): ?bool
  168. {
  169. return $this->isActive;
  170. }
  171. public function setIsActive(bool $isActive): self
  172. {
  173. $this->isActive = $isActive;
  174. return $this;
  175. }
  176. /**
  177. * @return Collection|Pricelist[]
  178. */
  179. public function getPricelists(): Collection
  180. {
  181. return $this->pricelists;
  182. }
  183. public function addPricelist(Pricelist $pricelist): self
  184. {
  185. if (!$this->pricelists->contains($pricelist)) {
  186. $this->pricelists[] = $pricelist;
  187. $pricelist->setVariant($this);
  188. }
  189. return $this;
  190. }
  191. public function removePricelist(Pricelist $pricelist): self
  192. {
  193. if ($this->pricelists->contains($pricelist)) {
  194. $this->pricelists->removeElement($pricelist);
  195. // set the owning side to null (unless already changed)
  196. if ($pricelist->getVariant() === $this) {
  197. $pricelist->setVariant(null);
  198. }
  199. }
  200. return $this;
  201. }
  202. /**
  203. * @return Collection|OrderItem[]
  204. */
  205. public function getOrderItems(): Collection
  206. {
  207. return $this->orderItems;
  208. }
  209. public function addOrderItem(OrderItem $orderItem): self
  210. {
  211. if (!$this->orderItems->contains($orderItem)) {
  212. $this->orderItems[] = $orderItem;
  213. $orderItem->setVariant($this);
  214. }
  215. return $this;
  216. }
  217. public function removeOrderItem(OrderItem $orderItem): self
  218. {
  219. if ($this->orderItems->contains($orderItem)) {
  220. $this->orderItems->removeElement($orderItem);
  221. // set the owning side to null (unless already changed)
  222. if ($orderItem->getVariant() === $this) {
  223. $orderItem->setVariant(null);
  224. }
  225. }
  226. return $this;
  227. }
  228. /**
  229. * Get PairedCode
  230. *
  231. * @return mixed
  232. */
  233. public function getPairedCode()
  234. {
  235. return $this->pairedCode;
  236. }
  237. /**
  238. * Set PairedCode
  239. *
  240. * @param mixed $pairedCode
  241. */
  242. public function setPairedCode( $pairedCode )
  243. {
  244. $this->pairedCode = $pairedCode;
  245. }
  246. }