src/Entity/Agence.php line 18

Open in your IDE?
  1. <?php
  2. /** @noinspection PhpPropertyOnlyWrittenInspection */
  3. namespace App\Entity;
  4. use App\Repository\AgenceRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use JMS\Serializer\Annotation as Serializer;
  9. use JMS\Serializer\Annotation\Expose;
  10. use JMS\Serializer\Annotation\Groups;
  11. /**
  12. * @ORM\Entity(repositoryClass=AgenceRepository::class)
  13. *
  14. * @Serializer\ExclusionPolicy("ALL")
  15. */
  16. class Agence
  17. {
  18. /**
  19. * @ORM\Id
  20. * @ORM\GeneratedValue
  21. * @ORM\Column(type="integer")
  22. *
  23. * @Expose
  24. * @Groups({
  25. * "default",
  26. * "agency_list","export_agency_datatable"
  27. * })
  28. */
  29. private $id;
  30. /**
  31. * @ORM\Column(type="string", length=16)
  32. *
  33. * @Expose
  34. * @Groups({
  35. * "agency_list","export_agency_datatable"
  36. * })
  37. */
  38. private ?string $code = null;
  39. /**
  40. * @ORM\Column(type="string", length=255)
  41. *
  42. * @Expose
  43. * @Groups({
  44. * "agency:name",
  45. * "agency_list","export_agency_datatable","user", "user_bussiness_result", "export_purchase_declaration_datatable", "export_agency_manager_commercial_datatable", "export_agency_manager_datatable", "export_commercial_installer_datatable", "export_commercial_datatable","get:read", "purchase", "export_installer_datatable",
  46. * "default",
  47. * "agency_list",
  48. * "export_agency_datatable","user", "user_bussiness_result", "export_purchase_declaration_datatable", "export_agency_manager_commercial_datatable",
  49. * "export_agency_manager_datatable", "export_commercial_installer_datatable", "export_commercial_datatable","get:read", "purchase", "export_installer_datatable"
  50. * })
  51. */
  52. private ?string $name = null;
  53. /**
  54. * @ORM\Column(type="string", length=255, nullable=true)
  55. */
  56. private ?string $region = null;
  57. /**
  58. * @ORM\Column(type="string", length=255, nullable=true)
  59. *
  60. * @Expose
  61. * @Groups({"agency_list","export_agency_datatable"})
  62. */
  63. private $managerLastName;
  64. /**
  65. * @ORM\Column(type="string", length=255, nullable=true)
  66. *
  67. * @Expose
  68. * @Groups({"agency_list","export_agency_datatable"})
  69. */
  70. private $managerFirstName;
  71. /**
  72. * @ORM\Column(type="string", length=255, nullable=true)
  73. *
  74. * @Expose
  75. * @Groups ({"export_agency_datatable"})
  76. */
  77. private $address1;
  78. /**
  79. * @ORM\Column(type="string", length=255, nullable=true)
  80. *
  81. * @Expose
  82. * @Groups ({"export_agency_datatable"})
  83. */
  84. private $address2;
  85. /**
  86. * @ORM\Column(type="string", length=255, nullable=true)
  87. *
  88. * @Expose
  89. * @Groups ({"export_agency_datatable"})
  90. */
  91. private $postCode;
  92. /**
  93. * @ORM\Column(type="string", length=255, nullable=true)
  94. *
  95. * @Expose
  96. * @Groups ({"export_agency_datatable"})
  97. */
  98. private $city;
  99. /**
  100. * @ORM\Column(type="string", length=255, nullable=true)
  101. *
  102. * @Expose
  103. * @Groups ({"export_agency_datatable"})
  104. */
  105. private $phone;
  106. /**
  107. * @ORM\OneToMany(targetEntity=User::class, mappedBy="agency")
  108. */
  109. private $users;
  110. public function __construct()
  111. {
  112. $this->users = new ArrayCollection();
  113. }
  114. public function __toString()
  115. {
  116. return $this->getName();
  117. }
  118. public function getName(): ?string
  119. {
  120. return $this->name;
  121. }
  122. public function setName(string $name): self
  123. {
  124. $this->name = $name;
  125. return $this;
  126. }
  127. public function getId(): ?int
  128. {
  129. return $this->id;
  130. }
  131. public function getCode(): ?string
  132. {
  133. return $this->code;
  134. }
  135. public function setCode(string $code): self
  136. {
  137. $this->code = $code;
  138. return $this;
  139. }
  140. public function getRegion(): ?string
  141. {
  142. return $this->region;
  143. }
  144. public function setRegion(string $region): self
  145. {
  146. $this->region = $region;
  147. return $this;
  148. }
  149. /**
  150. * @return mixed
  151. */
  152. public function getManagerLastName()
  153. {
  154. return $this->managerLastName;
  155. }
  156. /**
  157. * @param mixed $managerLastName
  158. *
  159. * @return Agence
  160. */
  161. public function setManagerLastName($managerLastName)
  162. {
  163. $this->managerLastName = $managerLastName;
  164. return $this;
  165. }
  166. /**
  167. * @return mixed
  168. */
  169. public function getManagerFirstName()
  170. {
  171. return $this->managerFirstName;
  172. }
  173. /**
  174. * @param mixed $managerFirstName
  175. *
  176. * @return Agence
  177. */
  178. public function setManagerFirstName($managerFirstName)
  179. {
  180. $this->managerFirstName = $managerFirstName;
  181. return $this;
  182. }
  183. /**
  184. * @return mixed
  185. */
  186. public function getAddress1()
  187. {
  188. return $this->address1;
  189. }
  190. /**
  191. * @param mixed $address1
  192. *
  193. * @return Agence
  194. */
  195. public function setAddress1($address1)
  196. {
  197. $this->address1 = $address1;
  198. return $this;
  199. }
  200. /**
  201. * @return mixed
  202. */
  203. public function getAddress2()
  204. {
  205. return $this->address2;
  206. }
  207. /**
  208. * @param mixed $address2
  209. *
  210. * @return Agence
  211. */
  212. public function setAddress2($address2)
  213. {
  214. $this->address2 = $address2;
  215. return $this;
  216. }
  217. /**
  218. * @return mixed
  219. */
  220. public function getPostCode()
  221. {
  222. return $this->postCode;
  223. }
  224. /**
  225. * @param mixed $postCode
  226. *
  227. * @return Agence
  228. */
  229. public function setPostCode($postCode)
  230. {
  231. $this->postCode = $postCode;
  232. return $this;
  233. }
  234. /**
  235. * @return mixed
  236. */
  237. public function getCity()
  238. {
  239. return $this->city;
  240. }
  241. /**
  242. * @param mixed $city
  243. *
  244. * @return Agence
  245. */
  246. public function setCity($city)
  247. {
  248. $this->city = $city;
  249. return $this;
  250. }
  251. /**
  252. * @return mixed
  253. */
  254. public function getPhone()
  255. {
  256. return $this->phone;
  257. }
  258. /**
  259. * @param mixed $phone
  260. *
  261. * @return Agence
  262. */
  263. public function setPhone($phone)
  264. {
  265. $this->phone = $phone;
  266. return $this;
  267. }
  268. /**
  269. * @return Collection|User[]
  270. */
  271. public function getUsers(): Collection
  272. {
  273. return $this->users;
  274. }
  275. public function addUser(User $user): self
  276. {
  277. if (!$this->users->contains($user)) {
  278. $this->users[] = $user;
  279. $user->setAgency($this);
  280. }
  281. return $this;
  282. }
  283. public function removeUser(User $user): self
  284. {
  285. if ($this->users->removeElement($user)) {
  286. // set the owning side to null (unless already changed)
  287. if ($user->getAgency() === $this) {
  288. $user->setAgency(null);
  289. }
  290. }
  291. return $this;
  292. }
  293. }