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)
  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)
  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. }
  186. return $this;
  187. }
  188. public function removeManager(User $manager): self
  189. {
  190. $this->managers->removeElement($manager);
  191. return $this;
  192. }
  193. public function getCreatedBy(): ?User
  194. {
  195. return $this->createdBy;
  196. }
  197. public function setCreatedBy(?User $createdBy): self
  198. {
  199. $this->createdBy = $createdBy;
  200. return $this;
  201. }
  202. public function getAddress(): ?PointOfSaleAddress
  203. {
  204. return $this->address;
  205. }
  206. public function setAddress(?PointOfSaleAddress $address): self
  207. {
  208. $this->address = $address;
  209. return $this;
  210. }
  211. public function getLogo(): ?string
  212. {
  213. return $this->logo;
  214. }
  215. public function setLogo(?string $logo): self
  216. {
  217. $this->logo = $logo;
  218. return $this;
  219. }
  220. public function getMailHeader(): ?string
  221. {
  222. return $this->mailHeader;
  223. }
  224. public function setMailHeader(?string $mailHeader): self
  225. {
  226. $this->mailHeader = $mailHeader;
  227. return $this;
  228. }
  229. }