src/Entity/Admin.php line 23

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