<?php
namespace App\Entity;
use App\Repository\ChildRepository;
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=ChildRepository::class)
*/
#[UniqueEntity(fields: ['email'], ignoreNull: true, message: 'This email is already registered.')]
#[UniqueEntity(fields: ['username'], ignoreNull: true, message: 'That username is taken.')]
class Child implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"GuardianList","ChildList","ResponsesList", "TeacherResponsesList", "DeclineHistoryList", "NotificationList","ChildPreferenceList", "ChildLessonReviewList"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"GuardianList","LessonList","ChildList","ResponsesList", "TeacherResponsesList", "ChildPreferenceAssignmentList", "DeclineHistoryList", "NotificationList", "ChildPreferenceList", "ChildLessonReviewList"})
*/
private $fullname;
/**
* @ORM\ManyToOne(targetEntity=Guardian::class, inversedBy="children")
* @Groups({"ChildList","ResponsesList", "TeacherResponsesList", "ChildPreferenceAssignmentList","LessonList", "DeclineHistoryList", "ChildPreferenceList"})
*/
private $guardian;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"GuardianList","ChildList", "TeacherResponsesList", "ChildPreferenceAssignmentList", "ChildLessonReviewList"})
*/
private $class;
/**
* @ORM\OneToMany(targetEntity=ChildPreference::class, mappedBy="child", cascade={"all"})
*/
private $childPreferences;
/**
* @ORM\OneToMany(targetEntity=ChildPreferenceHistory::class, mappedBy="child", cascade={"all"})
*/
private $childPreferenceHistories;
/**
* @ORM\ManyToMany(targetEntity=Lesson::class, mappedBy="children", cascade={"all"})
*/
private $lessons;
/**
* @ORM\OneToMany(targetEntity=TeacherComment::class, mappedBy="child", cascade={"all"})
*/
private $teacherComments;
/**
* @ORM\OneToMany(targetEntity=PaymentLog::class, mappedBy="child", cascade={"all"})
*/
private $paymentLogs;
/**
* @ORM\Column(type="date", nullable=true)
* @Groups({"ChildList"})
*/
private $birthDate;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $lessonsEnd;
/**
* @ORM\OneToMany(targetEntity=GuardianSurveyResponse::class, mappedBy="child")
*/
private $guardianSurveyResponses;
/**
* @ORM\OneToMany(targetEntity=TeacherSurveyResponse::class, mappedBy="child")
*/
private $teacherSurveyResponses;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"NotificationList"})
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
* @Assert\Length(min = 8, allowEmptyString = true)
*/
private $password = '';
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"NotificationList"})
*/
private $profileImagePath;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phoneNumber;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $lastname;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $fittingTimes;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $fittingTimesPriority;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $username;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $nextDayEmailLessonsRemindersGuardian = 1;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $nextDayEmailLessonsRemindersChild = 0;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $todaySMSLessonsRemindersGuardian = 1;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $todaySMSLessonsRemindersChild = 0;
/**
* @ORM\OneToMany(targetEntity=LessonLearncubeLog::class, mappedBy="child")
*/
private $lessonLearncubeLogs;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $passwordSentAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $showEmailModal;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $loginToken;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $googleRefreshToken;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $googleAccessToken = [];
/**
* @ORM\OneToMany(targetEntity=ChildVacation::class, mappedBy="child")
*/
private $childVacations;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $flagRU;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $flagPL;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $flagENG;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $flagIB;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $flagDyslexia;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $flagSensitive;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $school;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $flagStrict;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $gender;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $flagExperienceAtSchool;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $flagIelts;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $vbeOver90;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $experienceOver12Month;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $tutorComment;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $chatStreamToken;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $mobileAppLastUsedAt;
/**
* @ORM\OneToMany(targetEntity=ChildLessonReview::class, mappedBy="child")
*/
private $childLessonReviews;
public function __construct()
{
$this->childPreferences = new ArrayCollection();
$this->childPreferenceHistories = new ArrayCollection();
$this->lessons = new ArrayCollection();
$this->teacherComments = new ArrayCollection();
$this->paymentLogs = new ArrayCollection();
$this->guardianSurveyResponses = new ArrayCollection();
$this->teacherSurveyResponses = new ArrayCollection();
$this->lessonLearncubeLogs = new ArrayCollection();
$this->childVacations = new ArrayCollection();
$this->childLessonReviews = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getGuardian(): ?Guardian
{
return $this->guardian;
}
public function setGuardian(?Guardian $guardian): self
{
$this->guardian = $guardian;
return $this;
}
public function getFullname(): ?string
{
return $this->fullname;
}
public function setFullname(?string $fullname): self
{
$this->fullname = $fullname;
return $this;
}
public function getClass(): ?string
{
return $this->class;
}
public function setClass(?string $class): self
{
$this->class = $class;
return $this;
}
/**
* @return Collection|ChildPreferenceHistory[]
*/
public function getChildPreferenceHistories(): Collection
{
return $this->childPreferenceHistories;
}
/**
* @return Collection|ChildPreference[]
*/
public function getChildPreferences(): Collection
{
return $this->childPreferences;
}
public function addChildPreference(ChildPreference $childPreference): self
{
if (!$this->childPreferences->contains($childPreference)) {
$this->childPreferences[] = $childPreference;
$childPreference->setChild($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->getChild() === $this) {
$childPreference->setChild(null);
}
}
return $this;
}
public function __toString()
{
return "{$this->fullname} (" . $this->getGuardian()->getEmail() . ')';
}
public function getProfileImagePath(): ?string
{
return $this->profileImagePath;
}
public function setProfileImagePath(?string $profileImagePath): self
{
$this->profileImagePath = $profileImagePath;
return $this;
}
/**
* @return Collection|Lesson[]
*/
public function getLessons(): Collection
{
return $this->lessons;
}
public function addLesson(Lesson $lesson): self
{
if (!$this->lessons->contains($lesson)) {
$this->lessons[] = $lesson;
$lesson->addChild($this);
}
return $this;
}
public function removeLesson(Lesson $lesson): self
{
if ($this->lessons->removeElement($lesson)) {
$lesson->removeChild($this);
}
return $this;
}
/**
* @return Collection|TeacherComment[]
*/
public function getTeacherComments(): Collection
{
return $this->teacherComments;
}
public function addTeacherComment(TeacherComment $teacherComment): self
{
if (!$this->teacherComments->contains($teacherComment)) {
$this->teacherComments[] = $teacherComment;
$teacherComment->setChild($this);
}
return $this;
}
public function removeTeacherComment(TeacherComment $teacherComment): self
{
if ($this->teacherComments->removeElement($teacherComment)) {
// set the owning side to null (unless already changed)
if ($teacherComment->getChild() === $this) {
$teacherComment->setChild(null);
}
}
return $this;
}
/**
* @return Collection|PaymentLog[]
*/
public function getPaymentLogs(): Collection
{
return $this->paymentLogs;
}
public function addPaymentLog(PaymentLog $paymentLog): self
{
if (!$this->paymentLogs->contains($paymentLog)) {
$this->paymentLogs[] = $paymentLog;
$paymentLog->setChild($this);
}
return $this;
}
public function removePaymentLog(PaymentLog $paymentLog): self
{
if ($this->paymentLogs->removeElement($paymentLog)) {
// set the owning side to null (unless already changed)
if ($paymentLog->getChild() === $this) {
$paymentLog->setChild(null);
}
}
return $this;
}
public function getBirthDate(): ?\DateTimeInterface
{
return $this->birthDate;
}
public function setBirthDate(?\DateTimeInterface $birthDate): self
{
$this->birthDate = $birthDate;
return $this;
}
public function getLessonsEnd(): ?\DateTimeInterface
{
return $this->lessonsEnd;
}
public function setLessonsEnd(?\DateTimeInterface $lessonsEnd): self
{
$this->lessonsEnd = $lessonsEnd;
return $this;
}
/**
* @return Collection|GuardianSurveyResponse[]
*/
public function getGuardianSurveyResponses(): Collection
{
return $this->guardianSurveyResponses;
}
public function addGuardianSurveyResponse(GuardianSurveyResponse $guardianSurveyResponse): self
{
if (!$this->guardianSurveyResponses->contains($guardianSurveyResponse)) {
$this->guardianSurveyResponses[] = $guardianSurveyResponse;
$guardianSurveyResponse->setChild($this);
}
return $this;
}
public function removeGuardianSurveyResponse(GuardianSurveyResponse $guardianSurveyResponse): self
{
if ($this->guardianSurveyResponses->removeElement($guardianSurveyResponse)) {
// set the owning side to null (unless already changed)
if ($guardianSurveyResponse->getChild() === $this) {
$guardianSurveyResponse->setChild(null);
}
}
return $this;
}
/**
* @return Collection|TeacherSurveyResponse[]
*/
public function getTeacherSurveyResponses(): Collection
{
return $this->teacherSurveyResponses;
}
public function addTeacherSurveyResponse(TeacherSurveyResponse $teacherSurveyResponse): self
{
if (!$this->teacherSurveyResponses->contains($teacherSurveyResponse)) {
$this->teacherSurveyResponses[] = $teacherSurveyResponse;
$teacherSurveyResponse->setChild($this);
}
return $this;
}
public function removeTeacherSurveyResponse(TeacherSurveyResponse $teacherSurveyResponse): self
{
if ($this->teacherSurveyResponses->removeElement($teacherSurveyResponse)) {
// set the owning side to null (unless already changed)
if ($teacherSurveyResponse->getChild() === $this) {
$teacherSurveyResponse->setChild(null);
}
}
return $this;
}
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->username;
}
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = ['ROLE_CHILD', 'ROLE_USER'];
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$roles = ['ROLE_CHILD', 'ROLE_USER'];
$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 getPhoneNumber(): ?string
{
return $this->phoneNumber;
}
public function setPhoneNumber(?string $phoneNumber): self
{
$this->phoneNumber = $phoneNumber;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(?string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getFittingTimes(): ?string
{
return $this->fittingTimes;
}
public function setFittingTimes(?string $fittingTimes): self
{
$this->fittingTimes = $fittingTimes;
return $this;
}
public function getFittingTimesPriority(): ?string
{
return $this->fittingTimesPriority;
}
public function setFittingTimesPriority(?string $fittingTimesPriority): self
{
$this->fittingTimesPriority = $fittingTimesPriority;
return $this;
}
public function setUsername(?string $username): self
{
$this->username = $username;
return $this;
}
public function getNextDayEmailLessonsRemindersGuardian(): ?bool
{
return $this->nextDayEmailLessonsRemindersGuardian;
}
public function setNextDayEmailLessonsRemindersGuardian(?bool $nextDayEmailLessonsRemindersGuardian): self
{
$this->nextDayEmailLessonsRemindersGuardian = $nextDayEmailLessonsRemindersGuardian;
return $this;
}
public function getNextDayEmailLessonsRemindersChild(): ?bool
{
return $this->nextDayEmailLessonsRemindersChild;
}
public function setNextDayEmailLessonsRemindersChild(?bool $nextDayEmailLessonsRemindersChild): self
{
$this->nextDayEmailLessonsRemindersChild = $nextDayEmailLessonsRemindersChild;
return $this;
}
public function getTodaySMSLessonsRemindersGuardian(): ?bool
{
return $this->todaySMSLessonsRemindersGuardian;
}
public function setTodaySMSLessonsRemindersGuardian(?bool $todaySMSLessonsRemindersGuardian): self
{
$this->todaySMSLessonsRemindersGuardian = $todaySMSLessonsRemindersGuardian;
return $this;
}
public function getTodaySMSLessonsRemindersChild(): ?bool
{
return $this->todaySMSLessonsRemindersChild;
}
public function setTodaySMSLessonsRemindersChild(?bool $todaySMSLessonsRemindersChild): self
{
$this->todaySMSLessonsRemindersChild = $todaySMSLessonsRemindersChild;
return $this;
}
public function getUnickoFunction(): ?bool
{
$unickoFunction = false;
/**
* @var ChildPreference $childPreference
*/
foreach ($this->childPreferences as $childPreference) {
$teacher = $childPreference->getTeacher();
if (isset($teacher) && $teacher->getUnickoFunction()) {
$unickoFunction = true;
break;
}
}
return $unickoFunction;
}
/**
* @return Collection<int, LessonLearncubeLog>
*/
public function getLessonLearncubeLogs(): Collection
{
return $this->lessonLearncubeLogs;
}
public function addLessonLearncubeLog(LessonLearncubeLog $lessonLearncubeLog): self
{
if (!$this->lessonLearncubeLogs->contains($lessonLearncubeLog)) {
$this->lessonLearncubeLogs[] = $lessonLearncubeLog;
$lessonLearncubeLog->setChild($this);
}
return $this;
}
public function removeLessonLearncubeLog(LessonLearncubeLog $lessonLearncubeLog): self
{
if ($this->lessonLearncubeLogs->removeElement($lessonLearncubeLog)) {
// set the owning side to null (unless already changed)
if ($lessonLearncubeLog->getChild() === $this) {
$lessonLearncubeLog->setChild(null);
}
}
return $this;
}
public function getPasswordSentAt(): ?\DateTimeInterface
{
return $this->passwordSentAt;
}
public function setPasswordSentAt(?\DateTimeInterface $passwordSentAt): self
{
$this->passwordSentAt = $passwordSentAt;
return $this;
}
public function getShowEmailModal(): ?\DateTimeInterface
{
return $this->showEmailModal;
}
public function setShowEmailModal(?\DateTimeInterface $showEmailModal): self
{
$this->showEmailModal = $showEmailModal;
return $this;
}
public function showEmailSurvey()
{
$showModal = false;
if (!$this->getShowEmailModal() || (new \DateTime())->format('Y-m') != $this->getShowEmailModal()->format('Y-m')) {
if (!$this->getEmail()) {
$showModal = true;
}
}
return $showModal;
}
public function getLoginToken(): ?string
{
return $this->loginToken;
}
public function setLoginToken(?string $loginToken): self
{
$this->loginToken = $loginToken;
return $this;
}
public function getGoogleRefreshToken(): ?string
{
return $this->googleRefreshToken;
}
public function setGoogleRefreshToken(?string $googleRefreshToken): self
{
$this->googleRefreshToken = $googleRefreshToken;
return $this;
}
public function getGoogleAccessToken(): ?array
{
return $this->googleAccessToken;
}
public function setGoogleAccessToken(?array $googleAccessToken): self
{
$this->googleAccessToken = $googleAccessToken;
return $this;
}
/**
* @return Collection<int, ChildVacation>
*/
public function getChildVacations(): Collection
{
return $this->childVacations;
}
public function addChildVacation(ChildVacation $childVacation): self
{
if (!$this->childVacations->contains($childVacation)) {
$this->childVacations[] = $childVacation;
$childVacation->setChild($this);
}
return $this;
}
public function removeChildVacation(ChildVacation $childVacation): self
{
if ($this->childVacations->removeElement($childVacation)) {
// set the owning side to null (unless already changed)
if ($childVacation->getChild() === $this) {
$childVacation->setChild(null);
}
}
return $this;
}
public function getFlagRU(): ?bool
{
return $this->flagRU;
}
public function setFlagRU(?bool $flagRU): self
{
$this->flagRU = $flagRU;
return $this;
}
public function getFlagPL(): ?bool
{
return $this->flagPL;
}
public function setFlagPL(?bool $flagPL): self
{
$this->flagPL = $flagPL;
return $this;
}
public function getFlagENG(): ?bool
{
return $this->flagENG;
}
public function setFlagENG(?bool $flagENG): self
{
$this->flagENG = $flagENG;
return $this;
}
public function getFlagIB(): ?bool
{
return $this->flagIB;
}
public function setFlagIB(?bool $flagIB): self
{
$this->flagIB = $flagIB;
return $this;
}
public function getFlagDyslexia(): ?bool
{
return $this->flagDyslexia;
}
public function setFlagDyslexia(?bool $flagDyslexia): self
{
$this->flagDyslexia = $flagDyslexia;
return $this;
}
public function getFlagSensitive(): ?bool
{
return $this->flagSensitive;
}
public function setFlagSensitive(?bool $flagSensitive): self
{
$this->flagSensitive = $flagSensitive;
return $this;
}
public function getSchool(): ?string
{
return $this->school;
}
public function setSchool(?string $school): self
{
$this->school = $school;
return $this;
}
public function isFlagStrict(): ?bool
{
return $this->flagStrict;
}
public function setFlagStrict(?bool $flagStrict): self
{
$this->flagStrict = $flagStrict;
return $this;
}
public function getGender(): ?string
{
return $this->gender;
}
public function setGender(?string $gender): self
{
$this->gender = $gender;
return $this;
}
public function isFlagExperienceAtSchool(): ?bool
{
return $this->flagExperienceAtSchool;
}
public function setFlagExperienceAtSchool(?bool $flagExperienceAtSchool): self
{
$this->flagExperienceAtSchool = $flagExperienceAtSchool;
return $this;
}
public function isFlagIelts(): ?bool
{
return $this->flagIelts;
}
public function setFlagIelts(?bool $flagIelts): self
{
$this->flagIelts = $flagIelts;
return $this;
}
public function isVbeOver90(): ?bool
{
return $this->vbeOver90;
}
public function setVbeOver90(?bool $vbeOver90): self
{
$this->vbeOver90 = $vbeOver90;
return $this;
}
public function isExperienceOver12Month(): ?bool
{
return $this->experienceOver12Month;
}
public function setExperienceOver12Month(?bool $experienceOver12Month): self
{
$this->experienceOver12Month = $experienceOver12Month;
return $this;
}
public function getTutorComment(): ?string
{
return $this->tutorComment;
}
public function setTutorComment(?string $tutorComment): self
{
$this->tutorComment = $tutorComment;
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, ChildLessonReview>
*/
public function getChildLessonReviews(): Collection
{
return $this->childLessonReviews;
}
public function addChildLessonReview(ChildLessonReview $childLessonReview): self
{
if (!$this->childLessonReviews->contains($childLessonReview)) {
$this->childLessonReviews[] = $childLessonReview;
$childLessonReview->setChild($this);
}
return $this;
}
public function removeChildLessonReview(ChildLessonReview $childLessonReview): self
{
if ($this->childLessonReviews->removeElement($childLessonReview)) {
// set the owning side to null (unless already changed)
if ($childLessonReview->getChild() === $this) {
$childLessonReview->setChild(null);
}
}
return $this;
}
}