src/Entity/User.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Entity(repositoryClass: UserRepository::class)]
  11. class User implements UserInterface, PasswordAuthenticatedUserInterface
  12. {
  13. #[ORM\Id]
  14. #[ORM\GeneratedValue]
  15. #[ORM\Column]
  16. private ?int $id = null;
  17. #[ORM\Column(length: 180, unique: true)]
  18. private ?string $email = null;
  19. #[ORM\Column]
  20. private array $roles = [];
  21. /**
  22. * @var string The hashed password
  23. */
  24. #[ORM\Column]
  25. private ?string $password = null;
  26. #[ORM\Column(type: Types::DATE_MUTABLE)]
  27. private ?\DateTimeInterface $birthday = null;
  28. #[ORM\Column(length: 255)]
  29. private ?string $name = null;
  30. #[ORM\Column]
  31. private ?int $phone = null;
  32. #[ORM\Column(length: 10)]
  33. private ?string $gender = null;
  34. #[ORM\Column(length: 255)]
  35. private ?string $address = null;
  36. #[ORM\Column(length: 255, nullable: true)]
  37. private ?string $postalCode = null;
  38. #[ORM\Column(length: 50, nullable: true)]
  39. private ?string $country = null;
  40. #[ORM\Column(length: 50, nullable: true)]
  41. private ?string $state = null;
  42. #[ORM\Column(nullable: true)]
  43. private ?bool $blocked = null;
  44. #[ORM\Column(length: 65, nullable: true)]
  45. private ?string $token = null;
  46. #[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: Company::class)]
  47. private Collection $companies;
  48. #[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: BusTicket::class)]
  49. private Collection $busTickets;
  50. public function __construct()
  51. {
  52. $this->companies = new ArrayCollection();
  53. $this->busTickets = new ArrayCollection();
  54. }
  55. public function setSpecialId(int $id): ?self
  56. {
  57. $this->id = $id;
  58. return $this;
  59. }
  60. public function getId(): ?int
  61. {
  62. return $this->id;
  63. }
  64. public function getEmail(): ?string
  65. {
  66. return $this->email;
  67. }
  68. public function setEmail(string $email): self
  69. {
  70. $this->email = $email;
  71. return $this;
  72. }
  73. /**
  74. * A visual identifier that represents this user.
  75. *
  76. * @see UserInterface
  77. */
  78. public function getUserIdentifier(): string
  79. {
  80. return (string) $this->email;
  81. }
  82. /**
  83. * @deprecated since Symfony 5.3, use getUserIdentifier instead
  84. */
  85. public function getUsername(): string
  86. {
  87. return (string) $this->email;
  88. }
  89. /**
  90. * @see UserInterface
  91. */
  92. public function getRoles(): array
  93. {
  94. $roles = $this->roles;
  95. // guarantee every user at least has ROLE_USER
  96. $roles[] = 'ROLE_USER';
  97. return array_unique($roles);
  98. }
  99. public function setRoles(array $roles): self
  100. {
  101. $this->roles = $roles;
  102. return $this;
  103. }
  104. /**
  105. * @see PasswordAuthenticatedUserInterface
  106. */
  107. public function getPassword(): string
  108. {
  109. return $this->password;
  110. }
  111. public function setPassword(string $password): self
  112. {
  113. $this->password = $password;
  114. return $this;
  115. }
  116. /**
  117. * Returning a salt is only needed, if you are not using a modern
  118. * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  119. *
  120. * @see UserInterface
  121. */
  122. public function getSalt(): ?string
  123. {
  124. return null;
  125. }
  126. /**
  127. * @see UserInterface
  128. */
  129. public function eraseCredentials()
  130. {
  131. // If you store any temporary, sensitive data on the user, clear it here
  132. // $this->plainPassword = null;
  133. }
  134. public function getBirthday(): ?\DateTimeInterface
  135. {
  136. return $this->birthday;
  137. }
  138. public function setBirthday(\DateTimeInterface $birthday): self
  139. {
  140. $this->birthday = $birthday;
  141. return $this;
  142. }
  143. public function getName(): ?string
  144. {
  145. return $this->name;
  146. }
  147. public function setName(string $name): self
  148. {
  149. $this->name = $name;
  150. return $this;
  151. }
  152. public function getPhone(): ?int
  153. {
  154. return $this->phone;
  155. }
  156. public function setPhone(int $phone): self
  157. {
  158. $this->phone = $phone;
  159. return $this;
  160. }
  161. public function getGender(): ?string
  162. {
  163. return $this->gender;
  164. }
  165. public function setGender(string $gender): self
  166. {
  167. $this->gender = $gender;
  168. return $this;
  169. }
  170. public function getAddress(): ?string
  171. {
  172. return $this->address;
  173. }
  174. public function setAddress(string $address): self
  175. {
  176. $this->address = $address;
  177. return $this;
  178. }
  179. public function getPostalCode(): ?string
  180. {
  181. return $this->postalCode;
  182. }
  183. public function setPostalCode(?string $postalCode): self
  184. {
  185. $this->postalCode = $postalCode;
  186. return $this;
  187. }
  188. public function getCountry(): ?string
  189. {
  190. return $this->country;
  191. }
  192. public function setCountry(?string $country): self
  193. {
  194. $this->country = $country;
  195. return $this;
  196. }
  197. public function getState(): ?string
  198. {
  199. return $this->state;
  200. }
  201. public function setState(?string $state): self
  202. {
  203. $this->state = $state;
  204. return $this;
  205. }
  206. public function isBlocked(): ?bool
  207. {
  208. return $this->blocked;
  209. }
  210. public function setBlocked(?bool $blocked): self
  211. {
  212. $this->blocked = $blocked;
  213. return $this;
  214. }
  215. public function getToken(): ?string
  216. {
  217. return $this->token;
  218. }
  219. public function setToken(?string $token): self
  220. {
  221. $this->token = $token;
  222. return $this;
  223. }
  224. /**
  225. * @return Collection<int, Company>
  226. */
  227. public function getCompanies(): Collection
  228. {
  229. return $this->companies;
  230. }
  231. public function addCompany(Company $company): self
  232. {
  233. if (!$this->companies->contains($company)) {
  234. $this->companies->add($company);
  235. $company->setCreatedBy($this);
  236. }
  237. return $this;
  238. }
  239. public function removeCompany(Company $company): self
  240. {
  241. if ($this->companies->removeElement($company)) {
  242. // set the owning side to null (unless already changed)
  243. if ($company->getCreatedBy() === $this) {
  244. $company->setCreatedBy(null);
  245. }
  246. }
  247. return $this;
  248. }
  249. /**
  250. * @return Collection<int, BusTicket>
  251. */
  252. public function getBusTickets(): Collection
  253. {
  254. return $this->busTickets;
  255. }
  256. public function addBusTicket(BusTicket $busTicket): static
  257. {
  258. if (!$this->busTickets->contains($busTicket)) {
  259. $this->busTickets->add($busTicket);
  260. $busTicket->setCreatedBy($this);
  261. }
  262. return $this;
  263. }
  264. public function removeBusTicket(BusTicket $busTicket): static
  265. {
  266. if ($this->busTickets->removeElement($busTicket)) {
  267. // set the owning side to null (unless already changed)
  268. if ($busTicket->getCreatedBy() === $this) {
  269. $busTicket->setCreatedBy(null);
  270. }
  271. }
  272. return $this;
  273. }
  274. }