<?php
namespace App\Entity;
use App\Entity\Guardian\GuardianSMSResponse;
use App\Entity\GuardianRegister\GuardianRegister;
use App\Repository\AdminRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=AdminRepository::class)
* @ORM\Table(name="`admin`")
* @UniqueEntity("email")
*/
class Admin implements UserInterface, PasswordAuthenticatedUserInterface
{
const DEPARTMENT_DEV = 'dev';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"GuardianRegisterList","ChildPreferenceAssignmentList", "NotificationList", "AdminConfirmationsList","GuardianList"})
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
* @Groups({"showme", "NotificationList"})
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"CensorshipList","showme","GuardianRegisterList","ChildPreferenceAssignmentList", "NotificationList","TeacherRegisterList", "AdminConfirmationsList", "TeacherList","GuardianList"})
*/
private $fullname;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"NotificationList"})
*/
private $profileImagePath;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"showme"})
*/
private $phone;
/**
* @ORM\OneToMany(targetEntity=ChildPreference::class, mappedBy="adminUser")
*/
private $childPreferences;
/**
* @ORM\OneToMany(targetEntity=LessonDeleted::class, mappedBy="admin")
*/
private $lessonDeleteds;
/**
* @ORM\OneToMany(targetEntity=TeacherPaymentBonus::class, mappedBy="admin")
*/
private $teacherPaymentBonuses;
/**
* @ORM\OneToMany(targetEntity=TeacherHoursBonus::class, mappedBy="admin")
*/
private $teacherHoursBonuses;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $chatStreamToken;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $mobileAppLastUsedAt;
/**
* @ORM\OneToMany(targetEntity=BugReport::class, mappedBy="admin")
*/
private $bugReports;
/**
* @ORM\OneToMany(targetEntity=GuardianRegister::class, mappedBy="salesPerson")
*/
private $guardianRegisters;
/**
* @ORM\OneToMany(targetEntity=GuardianSMSResponse::class, mappedBy="lesson1AdminResponsed")
*/
private $smsLesson1Response;
/**
* @ORM\OneToMany(targetEntity=GuardianSMSResponse::class, mappedBy="lesson3AdminResponsed")
*/
private $smsLesson3Response;
/**
* @ORM\OneToMany(targetEntity=ChatCensorshipJournal::class, mappedBy="hr")
*/
private $chatCensorshipJournals;
/**
* @ORM\Column(type="string", length=20, nullable=true, options={"default": null})
*/
private ?string $department = null;
/**
* @ORM\Column(type="boolean", options={"default": 1})
*/
private bool $active = true;
public function __construct()
{
$this->childPreferences = new ArrayCollection();
$this->lessonDeleteds = new ArrayCollection();
$this->teacherPaymentBonuses = new ArrayCollection();
$this->teacherHoursBonuses = new ArrayCollection();
$this->bugReports = new ArrayCollection();
$this->guardianRegisters = new ArrayCollection();
$this->chatCensorshipJournals = new ArrayCollection();
$this->smsLesson1Response = new ArrayCollection();
$this->smsLesson3Response = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->email;
}
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = array_merge(['ROLE_ADMIN', 'ROLE_USER'], $this->roles);
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$roles = array_merge(['ROLE_ADMIN', 'ROLE_USER'], $roles);
$roles = array_unique($roles);
$this->roles = $roles;
return $this;
}
/**
* @see UserInterface
*/
public function getPassword(): string
{
return (string) $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function getSalt()
{
// not needed when using the "bcrypt" algorithm in security.yaml
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getFullname(): ?string
{
return $this->fullname;
}
public function setFullname(?string $fullname): self
{
$this->fullname = $fullname;
return $this;
}
public function getProfileImagePath(): ?string
{
return $this->profileImagePath;
}
public function setProfileImagePath(?string $profileImagePath): self
{
$this->profileImagePath = $profileImagePath;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function __toString()
{
return "{$this->getFullname()} {$this->getPhone()}";
}
/**
* @return Collection<int, ChildPreference>
*/
public function getChildPreferences(): Collection
{
return $this->childPreferences;
}
public function addChildPreference(ChildPreference $childPreference): self
{
if (!$this->childPreferences->contains($childPreference)) {
$this->childPreferences[] = $childPreference;
$childPreference->setAdminUser($this);
}
return $this;
}
public function removeChildPreference(ChildPreference $childPreference): self
{
if ($this->childPreferences->removeElement($childPreference)) {
// set the owning side to null (unless already changed)
if ($childPreference->getAdminUser() === $this) {
$childPreference->setAdminUser(null);
}
}
return $this;
}
/**
* @return Collection<int, LessonDeleted>
*/
public function getLessonDeleteds(): Collection
{
return $this->lessonDeleteds;
}
public function addLessonDeleted(LessonDeleted $lessonDeleted): self
{
if (!$this->lessonDeleteds->contains($lessonDeleted)) {
$this->lessonDeleteds[] = $lessonDeleted;
$lessonDeleted->setAdmin($this);
}
return $this;
}
public function removeLessonDeleted(LessonDeleted $lessonDeleted): self
{
if ($this->lessonDeleteds->removeElement($lessonDeleted)) {
// set the owning side to null (unless already changed)
if ($lessonDeleted->getAdmin() === $this) {
$lessonDeleted->setAdmin(null);
}
}
return $this;
}
/**
* @return Collection<int, TeacherPaymentBonus>
*/
public function getTeacherPaymentBonuses(): Collection
{
return $this->teacherPaymentBonuses;
}
public function addTeacherPaymentBonus(TeacherPaymentBonus $teacherPaymentBonus): self
{
if (!$this->teacherPaymentBonuses->contains($teacherPaymentBonus)) {
$this->teacherPaymentBonuses[] = $teacherPaymentBonus;
$teacherPaymentBonus->setAdmin($this);
}
return $this;
}
public function removeTeacherPaymentBonus(TeacherPaymentBonus $teacherPaymentBonus): self
{
if ($this->teacherPaymentBonuses->removeElement($teacherPaymentBonus)) {
// set the owning side to null (unless already changed)
if ($teacherPaymentBonus->getAdmin() === $this) {
$teacherPaymentBonus->setAdmin(null);
}
}
return $this;
}
/**
* @return Collection<int, TeacherHoursBonus>
*/
public function getTeacherHoursBonuses(): Collection
{
return $this->teacherHoursBonuses;
}
public function addTeacherHoursBonus(TeacherHoursBonus $teacherHoursBonus): self
{
if (!$this->teacherHoursBonuses->contains($teacherHoursBonus)) {
$this->teacherHoursBonuses[] = $teacherHoursBonus;
$teacherHoursBonus->setAdmin($this);
}
return $this;
}
public function removeTeacherHoursBonus(TeacherHoursBonus $teacherHoursBonus): self
{
if ($this->teacherHoursBonuses->removeElement($teacherHoursBonus)) {
// set the owning side to null (unless already changed)
if ($teacherHoursBonus->getAdmin() === $this) {
$teacherHoursBonus->setAdmin(null);
}
}
return $this;
}
public function getChatStreamToken(): ?string
{
return $this->chatStreamToken;
}
public function setChatStreamToken(?string $chatStreamToken): self
{
$this->chatStreamToken = $chatStreamToken;
return $this;
}
public function getMobileAppLastUsedAt(): ?\DateTimeInterface
{
return $this->mobileAppLastUsedAt;
}
public function setMobileAppLastUsedAt(?\DateTimeInterface $mobileAppLastUsedAt): self
{
$this->mobileAppLastUsedAt = $mobileAppLastUsedAt;
return $this;
}
/**
* @return Collection<int, BugReport>
*/
public function getBugReports(): Collection
{
return $this->bugReports;
}
public function addBugReport(BugReport $bugReport): self
{
if (!$this->bugReports->contains($bugReport)) {
$this->bugReports[] = $bugReport;
$bugReport->setAdmin($this);
}
return $this;
}
public function removeBugReport(BugReport $bugReport): self
{
if ($this->bugReports->removeElement($bugReport)) {
// set the owning side to null (unless already changed)
if ($bugReport->getAdmin() === $this) {
$bugReport->setAdmin(null);
}
}
return $this;
}
/**
* @return Collection<int, ChatCensorshipJournal>
*/
public function getChatCensorshipJournals(): Collection
{
return $this->chatCensorshipJournals;
}
public function addChatCensorshipJournal(ChatCensorshipJournal $chatCensorshipJournal): self
{
if (!$this->chatCensorshipJournals->contains($chatCensorshipJournal)) {
$this->chatCensorshipJournals[] = $chatCensorshipJournal;
$chatCensorshipJournal->setHr($this);
}
return $this;
}
public function removeChatCensorshipJournal(ChatCensorshipJournal $chatCensorshipJournal): self
{
if ($this->chatCensorshipJournals->removeElement($chatCensorshipJournal)) {
// set the owning side to null (unless already changed)
if ($chatCensorshipJournal->getHr() === $this) {
$chatCensorshipJournal->setHr(null);
}
}
return $this;
}
public function getDepartment(): ?string
{
return $this->department;
}
public function setDepartment(?string $department): self
{
$this->department = $department;
return $this;
}
public function isActive(): bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
}