src/Entity/PointOfSale.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PointOfSaleRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. use JMS\Serializer\Annotation\Expose;
  9. use JMS\Serializer\Annotation\Groups;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. /**
  12. * @ORM\Entity(repositoryClass=PointOfSaleRepository::class)
  13. *
  14. * @UniqueEntity("code")
  15. *
  16. * @Serializer\ExclusionPolicy("ALL")
  17. */
  18. class PointOfSale
  19. {
  20. /**
  21. * Identifiant unique
  22. *
  23. * @ORM\Id
  24. * @ORM\GeneratedValue
  25. * @ORM\Column(type="integer")
  26. *
  27. * @Expose
  28. * @Groups({"export_point_of_sale_datatable", "point_of_sale","point_sale"})
  29. */
  30. private ?int $id = null;
  31. /**
  32. * Code
  33. *
  34. * @ORM\Column(type="string", length=10, unique=true, nullable=true)
  35. *
  36. * @Expose
  37. * @Groups({"export_point_of_sale_datatable", "point_of_sale", "user"})
  38. */
  39. private ?string $code = null;
  40. /**
  41. * Nom
  42. *
  43. * @ORM\Column(type="string", length=255)
  44. *
  45. * @Expose
  46. * @Groups({"export_point_of_sale_datatable", "point_of_sale", "user"})
  47. */
  48. private ?string $name = null;
  49. /**
  50. * Ville
  51. *
  52. * @ORM\Column(type="string", length=255, nullable=true)
  53. *
  54. * @Expose
  55. * @Groups({ "export_point_of_sale_datatable", "point_of_sale", "user"})
  56. */
  57. private ?string $city = null;
  58. /**
  59. * Actif / Inactif
  60. *
  61. * @ORM\Column(type="boolean", options={"default":true})
  62. *
  63. * @Expose
  64. * @Groups({ "export_point_of_sale_datatable", "point_of_sale"})
  65. */
  66. private ?bool $enabled = true;
  67. /**
  68. * Utilisateur dans le point de vente
  69. *
  70. * @ORM\OneToMany(targetEntity=User::class, mappedBy="pointOfSale")
  71. * @Expose
  72. * @Groups({"point_of_sale"})
  73. */
  74. private Collection $users;
  75. /**
  76. * Utilisateurs qui gèrent le point de vente
  77. *
  78. * @ORM\ManyToMany(targetEntity=User::class, inversedBy="managedPointOfSales")
  79. */
  80. private Collection $managers;
  81. /**
  82. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="createdPointOfSales")
  83. *
  84. * @Expose
  85. * @Groups({"point_of_sale"})
  86. */
  87. private ?User $createdBy = null;
  88. /**
  89. * @ORM\OneToOne(targetEntity=PointOfSaleAddress::class, cascade={"persist", "remove"})
  90. */
  91. private ?PointOfSaleAddress $address = null;
  92. /**
  93. * @ORM\Column(type="string", length=255, nullable=true)
  94. */
  95. private $logo = null;
  96. /**
  97. * @ORM\Column(type="string", length=255, nullable=true)
  98. */
  99. private $mailHeader = null;
  100. public function __construct()
  101. {
  102. $this->users = new ArrayCollection();
  103. $this->managers = new ArrayCollection();
  104. }
  105. public function __toString()
  106. {
  107. return $this->getCode();
  108. }
  109. public function getId(): ?int
  110. {
  111. return $this->id;
  112. }
  113. public function getCode(): ?string
  114. {
  115. return $this->code;
  116. }
  117. public function setCode(string $code): self
  118. {
  119. $this->code = $code;
  120. return $this;
  121. }
  122. public function getName(): ?string
  123. {
  124. return $this->name;
  125. }
  126. public function setName(string $name): self
  127. {
  128. $this->name = $name;
  129. return $this;
  130. }
  131. public function getCity(): ?string
  132. {
  133. return $this->city;
  134. }
  135. public function setCity(string $city): self
  136. {
  137. $this->city = $city;
  138. return $this;
  139. }
  140. /**
  141. * @return Collection<int, User>
  142. */
  143. public function getUsers(): Collection
  144. {
  145. return $this->users;
  146. }
  147. public function addUser(User $user): self
  148. {
  149. if (!$this->users->contains($user)) {
  150. $this->users[] = $user;
  151. $user->setPointOfSale($this);
  152. }
  153. return $this;
  154. }
  155. public function removeUser(User $user): self
  156. {
  157. if ($this->users->removeElement($user)) {
  158. // set the owning side to null (unless already changed)
  159. if ($user->getPointOfSale() === $this) {
  160. $user->setPointOfSale(null);
  161. }
  162. }
  163. return $this;
  164. }
  165. public function isEnabled(): ?bool
  166. {
  167. return $this->enabled;
  168. }
  169. public function setEnabled(bool $enabled): self
  170. {
  171. $this->enabled = $enabled;
  172. return $this;
  173. }
  174. /**
  175. * @return Collection<int, User>
  176. */
  177. public function getManagers(): Collection
  178. {
  179. return $this->managers;
  180. }
  181. public function addManager(User $manager): self
  182. {
  183. if (!$this->managers->contains($manager)) {
  184. $this->managers[] = $manager;
  185. if (!$manager->getManagedPointOfSales()->contains($this)) {
  186. $manager->addManagedPointOfSale($this);
  187. }
  188. }
  189. return $this;
  190. }
  191. public function removeManager(User $manager): self
  192. {
  193. if ($this->managers->removeElement($manager)) {
  194. if ($manager->getManagedPointOfSales()->contains($this)) {
  195. $manager->removeManagedPointOfSale($this);
  196. }
  197. }
  198. return $this;
  199. }
  200. public function getCreatedBy(): ?User
  201. {
  202. return $this->createdBy;
  203. }
  204. public function setCreatedBy(?User $createdBy): self
  205. {
  206. $this->createdBy = $createdBy;
  207. return $this;
  208. }
  209. public function getAddress(): ?PointOfSaleAddress
  210. {
  211. return $this->address;
  212. }
  213. public function setAddress(?PointOfSaleAddress $address): self
  214. {
  215. $this->address = $address;
  216. return $this;
  217. }
  218. public function getLogo(): ?string
  219. {
  220. return $this->logo;
  221. }
  222. public function setLogo(?string $logo): self
  223. {
  224. $this->logo = $logo;
  225. return $this;
  226. }
  227. public function getMailHeader(): ?string
  228. {
  229. return $this->mailHeader;
  230. }
  231. public function setMailHeader(?string $mailHeader): self
  232. {
  233. $this->mailHeader = $mailHeader;
  234. return $this;
  235. }
  236. }