src/Entity/Admin.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Guardian\GuardianSMSResponse;
  4. use App\Entity\GuardianRegister\GuardianRegister;
  5. use App\Repository\AdminRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  11. use Symfony\Component\Security\Core\User\UserInterface;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. /**
  15. * @ORM\Entity(repositoryClass=AdminRepository::class)
  16. * @ORM\Table(name="`admin`")
  17. * @UniqueEntity("email")
  18. */
  19. class Admin implements UserInterface, PasswordAuthenticatedUserInterface
  20. {
  21. const DEPARTMENT_DEV = 'dev';
  22. /**
  23. * @ORM\Id
  24. * @ORM\GeneratedValue
  25. * @ORM\Column(type="integer")
  26. * @Groups({"GuardianRegisterList","ChildPreferenceAssignmentList", "NotificationList", "AdminConfirmationsList","GuardianList"})
  27. */
  28. private $id;
  29. /**
  30. * @ORM\Column(type="string", length=180, unique=true)
  31. * @Groups({"showme", "NotificationList"})
  32. */
  33. private $email;
  34. /**
  35. * @ORM\Column(type="json")
  36. */
  37. private $roles = [];
  38. /**
  39. * @var string The hashed password
  40. * @ORM\Column(type="string")
  41. */
  42. private $password;
  43. /**
  44. * @ORM\Column(type="string", length=255, nullable=true)
  45. * @Groups({"CensorshipList","showme","GuardianRegisterList","ChildPreferenceAssignmentList", "NotificationList","TeacherRegisterList", "AdminConfirmationsList", "TeacherList","GuardianList"})
  46. */
  47. private $fullname;
  48. /**
  49. * @ORM\Column(type="string", length=255, nullable=true)
  50. * @Groups({"NotificationList"})
  51. */
  52. private $profileImagePath;
  53. /**
  54. * @ORM\Column(type="string", length=255, nullable=true)
  55. * @Groups({"showme"})
  56. */
  57. private $phone;
  58. /**
  59. * @ORM\OneToMany(targetEntity=ChildPreference::class, mappedBy="adminUser")
  60. */
  61. private $childPreferences;
  62. /**
  63. * @ORM\OneToMany(targetEntity=LessonDeleted::class, mappedBy="admin")
  64. */
  65. private $lessonDeleteds;
  66. /**
  67. * @ORM\OneToMany(targetEntity=TeacherPaymentBonus::class, mappedBy="admin")
  68. */
  69. private $teacherPaymentBonuses;
  70. /**
  71. * @ORM\OneToMany(targetEntity=TeacherHoursBonus::class, mappedBy="admin")
  72. */
  73. private $teacherHoursBonuses;
  74. /**
  75. * @ORM\Column(type="text", nullable=true)
  76. */
  77. private $chatStreamToken;
  78. /**
  79. * @ORM\Column(type="datetime", nullable=true)
  80. */
  81. private $mobileAppLastUsedAt;
  82. /**
  83. * @ORM\OneToMany(targetEntity=BugReport::class, mappedBy="admin")
  84. */
  85. private $bugReports;
  86. /**
  87. * @ORM\OneToMany(targetEntity=GuardianRegister::class, mappedBy="salesPerson")
  88. */
  89. private $guardianRegisters;
  90. /**
  91. * @ORM\OneToMany(targetEntity=GuardianSMSResponse::class, mappedBy="lesson1AdminResponsed")
  92. */
  93. private $smsLesson1Response;
  94. /**
  95. * @ORM\OneToMany(targetEntity=GuardianSMSResponse::class, mappedBy="lesson3AdminResponsed")
  96. */
  97. private $smsLesson3Response;
  98. /**
  99. * @ORM\OneToMany(targetEntity=ChatCensorshipJournal::class, mappedBy="hr")
  100. */
  101. private $chatCensorshipJournals;
  102. /**
  103. * @ORM\Column(type="string", length=20, nullable=true, options={"default": null})
  104. */
  105. private ?string $department = null;
  106. /**
  107. * @ORM\Column(type="boolean", options={"default": 1})
  108. */
  109. private bool $active = true;
  110. public function __construct()
  111. {
  112. $this->childPreferences = new ArrayCollection();
  113. $this->lessonDeleteds = new ArrayCollection();
  114. $this->teacherPaymentBonuses = new ArrayCollection();
  115. $this->teacherHoursBonuses = new ArrayCollection();
  116. $this->bugReports = new ArrayCollection();
  117. $this->guardianRegisters = new ArrayCollection();
  118. $this->chatCensorshipJournals = new ArrayCollection();
  119. $this->smsLesson1Response = new ArrayCollection();
  120. $this->smsLesson3Response = new ArrayCollection();
  121. }
  122. public function getId(): ?int
  123. {
  124. return $this->id;
  125. }
  126. public function getEmail(): ?string
  127. {
  128. return $this->email;
  129. }
  130. public function setEmail(string $email): self
  131. {
  132. $this->email = $email;
  133. return $this;
  134. }
  135. /**
  136. * A visual identifier that represents this user.
  137. *
  138. * @see UserInterface
  139. */
  140. public function getUsername(): string
  141. {
  142. return (string) $this->email;
  143. }
  144. public function getUserIdentifier(): string
  145. {
  146. return (string) $this->email;
  147. }
  148. /**
  149. * @see UserInterface
  150. */
  151. public function getRoles(): array
  152. {
  153. $roles = array_merge(['ROLE_ADMIN', 'ROLE_USER'], $this->roles);
  154. return array_unique($roles);
  155. }
  156. public function setRoles(array $roles): self
  157. {
  158. $roles = array_merge(['ROLE_ADMIN', 'ROLE_USER'], $roles);
  159. $roles = array_unique($roles);
  160. $this->roles = $roles;
  161. return $this;
  162. }
  163. /**
  164. * @see UserInterface
  165. */
  166. public function getPassword(): string
  167. {
  168. return (string) $this->password;
  169. }
  170. public function setPassword(string $password): self
  171. {
  172. $this->password = $password;
  173. return $this;
  174. }
  175. /**
  176. * @see UserInterface
  177. */
  178. public function getSalt()
  179. {
  180. // not needed when using the "bcrypt" algorithm in security.yaml
  181. }
  182. /**
  183. * @see UserInterface
  184. */
  185. public function eraseCredentials()
  186. {
  187. // If you store any temporary, sensitive data on the user, clear it here
  188. // $this->plainPassword = null;
  189. }
  190. public function getFullname(): ?string
  191. {
  192. return $this->fullname;
  193. }
  194. public function setFullname(?string $fullname): self
  195. {
  196. $this->fullname = $fullname;
  197. return $this;
  198. }
  199. public function getProfileImagePath(): ?string
  200. {
  201. return $this->profileImagePath;
  202. }
  203. public function setProfileImagePath(?string $profileImagePath): self
  204. {
  205. $this->profileImagePath = $profileImagePath;
  206. return $this;
  207. }
  208. public function getPhone(): ?string
  209. {
  210. return $this->phone;
  211. }
  212. public function setPhone(?string $phone): self
  213. {
  214. $this->phone = $phone;
  215. return $this;
  216. }
  217. public function __toString()
  218. {
  219. return "{$this->getFullname()} {$this->getPhone()}";
  220. }
  221. /**
  222. * @return Collection<int, ChildPreference>
  223. */
  224. public function getChildPreferences(): Collection
  225. {
  226. return $this->childPreferences;
  227. }
  228. public function addChildPreference(ChildPreference $childPreference): self
  229. {
  230. if (!$this->childPreferences->contains($childPreference)) {
  231. $this->childPreferences[] = $childPreference;
  232. $childPreference->setAdminUser($this);
  233. }
  234. return $this;
  235. }
  236. public function removeChildPreference(ChildPreference $childPreference): self
  237. {
  238. if ($this->childPreferences->removeElement($childPreference)) {
  239. // set the owning side to null (unless already changed)
  240. if ($childPreference->getAdminUser() === $this) {
  241. $childPreference->setAdminUser(null);
  242. }
  243. }
  244. return $this;
  245. }
  246. /**
  247. * @return Collection<int, LessonDeleted>
  248. */
  249. public function getLessonDeleteds(): Collection
  250. {
  251. return $this->lessonDeleteds;
  252. }
  253. public function addLessonDeleted(LessonDeleted $lessonDeleted): self
  254. {
  255. if (!$this->lessonDeleteds->contains($lessonDeleted)) {
  256. $this->lessonDeleteds[] = $lessonDeleted;
  257. $lessonDeleted->setAdmin($this);
  258. }
  259. return $this;
  260. }
  261. public function removeLessonDeleted(LessonDeleted $lessonDeleted): self
  262. {
  263. if ($this->lessonDeleteds->removeElement($lessonDeleted)) {
  264. // set the owning side to null (unless already changed)
  265. if ($lessonDeleted->getAdmin() === $this) {
  266. $lessonDeleted->setAdmin(null);
  267. }
  268. }
  269. return $this;
  270. }
  271. /**
  272. * @return Collection<int, TeacherPaymentBonus>
  273. */
  274. public function getTeacherPaymentBonuses(): Collection
  275. {
  276. return $this->teacherPaymentBonuses;
  277. }
  278. public function addTeacherPaymentBonus(TeacherPaymentBonus $teacherPaymentBonus): self
  279. {
  280. if (!$this->teacherPaymentBonuses->contains($teacherPaymentBonus)) {
  281. $this->teacherPaymentBonuses[] = $teacherPaymentBonus;
  282. $teacherPaymentBonus->setAdmin($this);
  283. }
  284. return $this;
  285. }
  286. public function removeTeacherPaymentBonus(TeacherPaymentBonus $teacherPaymentBonus): self
  287. {
  288. if ($this->teacherPaymentBonuses->removeElement($teacherPaymentBonus)) {
  289. // set the owning side to null (unless already changed)
  290. if ($teacherPaymentBonus->getAdmin() === $this) {
  291. $teacherPaymentBonus->setAdmin(null);
  292. }
  293. }
  294. return $this;
  295. }
  296. /**
  297. * @return Collection<int, TeacherHoursBonus>
  298. */
  299. public function getTeacherHoursBonuses(): Collection
  300. {
  301. return $this->teacherHoursBonuses;
  302. }
  303. public function addTeacherHoursBonus(TeacherHoursBonus $teacherHoursBonus): self
  304. {
  305. if (!$this->teacherHoursBonuses->contains($teacherHoursBonus)) {
  306. $this->teacherHoursBonuses[] = $teacherHoursBonus;
  307. $teacherHoursBonus->setAdmin($this);
  308. }
  309. return $this;
  310. }
  311. public function removeTeacherHoursBonus(TeacherHoursBonus $teacherHoursBonus): self
  312. {
  313. if ($this->teacherHoursBonuses->removeElement($teacherHoursBonus)) {
  314. // set the owning side to null (unless already changed)
  315. if ($teacherHoursBonus->getAdmin() === $this) {
  316. $teacherHoursBonus->setAdmin(null);
  317. }
  318. }
  319. return $this;
  320. }
  321. public function getChatStreamToken(): ?string
  322. {
  323. return $this->chatStreamToken;
  324. }
  325. public function setChatStreamToken(?string $chatStreamToken): self
  326. {
  327. $this->chatStreamToken = $chatStreamToken;
  328. return $this;
  329. }
  330. public function getMobileAppLastUsedAt(): ?\DateTimeInterface
  331. {
  332. return $this->mobileAppLastUsedAt;
  333. }
  334. public function setMobileAppLastUsedAt(?\DateTimeInterface $mobileAppLastUsedAt): self
  335. {
  336. $this->mobileAppLastUsedAt = $mobileAppLastUsedAt;
  337. return $this;
  338. }
  339. /**
  340. * @return Collection<int, BugReport>
  341. */
  342. public function getBugReports(): Collection
  343. {
  344. return $this->bugReports;
  345. }
  346. public function addBugReport(BugReport $bugReport): self
  347. {
  348. if (!$this->bugReports->contains($bugReport)) {
  349. $this->bugReports[] = $bugReport;
  350. $bugReport->setAdmin($this);
  351. }
  352. return $this;
  353. }
  354. public function removeBugReport(BugReport $bugReport): self
  355. {
  356. if ($this->bugReports->removeElement($bugReport)) {
  357. // set the owning side to null (unless already changed)
  358. if ($bugReport->getAdmin() === $this) {
  359. $bugReport->setAdmin(null);
  360. }
  361. }
  362. return $this;
  363. }
  364. /**
  365. * @return Collection<int, ChatCensorshipJournal>
  366. */
  367. public function getChatCensorshipJournals(): Collection
  368. {
  369. return $this->chatCensorshipJournals;
  370. }
  371. public function addChatCensorshipJournal(ChatCensorshipJournal $chatCensorshipJournal): self
  372. {
  373. if (!$this->chatCensorshipJournals->contains($chatCensorshipJournal)) {
  374. $this->chatCensorshipJournals[] = $chatCensorshipJournal;
  375. $chatCensorshipJournal->setHr($this);
  376. }
  377. return $this;
  378. }
  379. public function removeChatCensorshipJournal(ChatCensorshipJournal $chatCensorshipJournal): self
  380. {
  381. if ($this->chatCensorshipJournals->removeElement($chatCensorshipJournal)) {
  382. // set the owning side to null (unless already changed)
  383. if ($chatCensorshipJournal->getHr() === $this) {
  384. $chatCensorshipJournal->setHr(null);
  385. }
  386. }
  387. return $this;
  388. }
  389. public function getDepartment(): ?string
  390. {
  391. return $this->department;
  392. }
  393. public function setDepartment(?string $department): self
  394. {
  395. $this->department = $department;
  396. return $this;
  397. }
  398. public function isActive(): bool
  399. {
  400. return $this->active;
  401. }
  402. public function setActive(bool $active): self
  403. {
  404. $this->active = $active;
  405. return $this;
  406. }
  407. }