diff --git a/src/Entity/Announcement.php b/src/Entity/Announcement.php index 41bcf91..5cf1c55 100644 --- a/src/Entity/Announcement.php +++ b/src/Entity/Announcement.php @@ -30,21 +30,21 @@ class Announcement private ?Status $status = null; /** - * @var Collection + * @var Collection */ - #[ORM\ManyToMany(targetEntity: Intern::class, mappedBy: 'favorites')] - private Collection $internsfav; + #[ORM\OneToMany(targetEntity: InternApplication::class, mappedBy: 'application')] + private Collection $applicants; /** - * @var Collection + * @var Collection */ - #[ORM\ManyToMany(targetEntity: Intern::class, mappedBy: 'applications')] - private Collection $applicants; + #[ORM\OneToMany(targetEntity: InternFavorite::class, mappedBy: 'announcement')] + private Collection $favoritesInterns; public function __construct() { - $this->internsfav = new ArrayCollection(); $this->applicants = new ArrayCollection(); + $this->favoritesInterns = new ArrayCollection(); } public function getId(): ?int @@ -101,54 +101,60 @@ class Announcement } /** - * @return Collection - */ - public function getInternsfav(): Collection - { - return $this->internsfav; - } - - public function addInternfav(Intern $intern): static - { - if (!$this->internsfav->contains($intern)) { - $this->internsfav->add($intern); - $intern->addFavorite($this); - } - - return $this; - } - - public function removeInternfav(Intern $intern): static - { - if ($this->internsfav->removeElement($intern)) { - $intern->removeFavorite($this); - } - - return $this; - } - - /** - * @return Collection + * @return Collection */ public function getApplicants(): Collection { return $this->applicants; } - public function addApplicant(Intern $applicant): static + public function addApplicants(InternApplication $applicants): static { - if (!$this->applicants->contains($applicant)) { - $this->applicants->add($applicant); - $applicant->addApplication($this); + if (!$this->applicants->contains($applicants)) { + $this->applicants->add($applicants); + $applicants->setApplication($this); } return $this; } - public function removeApplicant(Intern $applicant): static + public function removeApplicants(InternApplication $applicants): static { - if ($this->applicants->removeElement($applicant)) { - $applicant->removeApplication($this); + if ($this->applicants->removeElement($applicants)) { + // set the owning side to null (unless already changed) + if ($applicants->getApplication() === $this) { + $applicants->setApplication(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getFavoritesInterns(): Collection + { + return $this->favoritesInterns; + } + + public function addFavoritesIntern(InternFavorite $favoritesIntern): static + { + if (!$this->favoritesInterns->contains($favoritesIntern)) { + $this->favoritesInterns->add($favoritesIntern); + $favoritesIntern->setAnnouncement($this); + } + + return $this; + } + + public function removeFavoritesIntern(InternFavorite $favoritesIntern): static + { + if ($this->favoritesInterns->removeElement($favoritesIntern)) { + // set the owning side to null (unless already changed) + if ($favoritesIntern->getAnnouncement() === $this) { + $favoritesIntern->setAnnouncement(null); + } } return $this; diff --git a/src/Entity/Degree.php b/src/Entity/Degree.php new file mode 100644 index 0000000..228a32d --- /dev/null +++ b/src/Entity/Degree.php @@ -0,0 +1,78 @@ + + */ + #[ORM\OneToMany(targetEntity: InternDegree::class, mappedBy: 'degree')] + private Collection $interns; + + public function __construct() + { + $this->interns = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getLabel(): ?string + { + return $this->label; + } + + public function setLabel(string $label): static + { + $this->label = $label; + + return $this; + } + + /** + * @return Collection + */ + public function getInterns(): Collection + { + return $this->interns; + } + + public function addIntern(InternDegree $intern): static + { + if (!$this->interns->contains($intern)) { + $this->interns->add($intern); + $intern->setDegree($this); + } + + return $this; + } + + public function removeIntern(InternDegree $intern): static + { + if ($this->interns->removeElement($intern)) { + // set the owning side to null (unless already changed) + if ($intern->getDegree() === $this) { + $intern->setDegree(null); + } + } + + return $this; + } +} diff --git a/src/Entity/Intern.php b/src/Entity/Intern.php index b03dcd8..2ca1f8e 100644 --- a/src/Entity/Intern.php +++ b/src/Entity/Intern.php @@ -19,30 +19,35 @@ class Intern extends UserApp private ?string $resume = null; /** - * @var Collection + * @var Collection */ - #[ORM\ManyToMany(targetEntity: Announcement::class, inversedBy: 'interns')] - #[ORM\JoinTable(name: 'favorites')] - private Collection $favorites; + #[ORM\OneToMany(targetEntity: InternDegree::class, mappedBy: 'intern')] + private Collection $degrees; /** - * @var Collection + * @var Collection */ - #[ORM\ManyToMany(targetEntity: Announcement::class, inversedBy: 'applicants')] - #[ORM\JoinTable(name: 'applications')] + #[ORM\OneToMany(targetEntity: InternSkill::class, mappedBy: 'intern')] + private Collection $skills; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: InternApplication::class, mappedBy: 'intern')] private Collection $applications; /** - * @var Collection + * @var Collection */ - #[ORM\ManyToMany(targetEntity: Skill::class, inversedBy: 'interns')] - private Collection $skills; + #[ORM\OneToMany(targetEntity: InternFavorite::class, mappedBy: 'intern')] + private Collection $favorites; public function __construct() { - $this->favorites = new ArrayCollection(); - $this->applications = new ArrayCollection(); + $this->degrees = new ArrayCollection(); $this->skills = new ArrayCollection(); + $this->applications = new ArrayCollection(); + $this->favorites = new ArrayCollection(); } public function getCoverLetter(): ?string @@ -70,73 +75,121 @@ class Intern extends UserApp } /** - * @return Collection + * @return Collection */ - public function getFavorites(): Collection + public function getDegrees(): Collection { - return $this->favorites; + return $this->degrees; } - public function addFavorite(Announcement $favorite): static + public function addDegree(InternDegree $degree): static { - if (!$this->favorites->contains($favorite)) { - $this->favorites->add($favorite); + if (!$this->degrees->contains($degree)) { + $this->degrees->add($degree); + $degree->setIntern($this); } return $this; } - public function removeFavorite(Announcement $favorite): static + public function removeDegree(InternDegree $degree): static { - $this->favorites->removeElement($favorite); - - return $this; - } - - /** - * @return Collection - */ - public function getApplications(): Collection - { - return $this->applications; - } - - public function addApplication(Announcement $application): static - { - if (!$this->applications->contains($application)) { - $this->applications->add($application); + if ($this->degrees->removeElement($degree)) { + // set the owning side to null (unless already changed) + if ($degree->getIntern() === $this) { + $degree->setIntern(null); + } } return $this; } - public function removeApplication(Announcement $application): static - { - $this->applications->removeElement($application); - - return $this; - } - /** - * @return Collection + * @return Collection */ public function getSkills(): Collection { return $this->skills; } - public function addSkill(Skill $skill): static + public function addSkill(InternSkill $skill): static { if (!$this->skills->contains($skill)) { $this->skills->add($skill); + $skill->setIntern($this); } return $this; } - public function removeSkill(Skill $skill): static + public function removeSkill(InternSkill $skill): static { - $this->skills->removeElement($skill); + if ($this->skills->removeElement($skill)) { + // set the owning side to null (unless already changed) + if ($skill->getIntern() === $this) { + $skill->setIntern(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getApplications(): Collection + { + return $this->applications; + } + + public function addApplication(InternApplication $application): static + { + if (!$this->applications->contains($application)) { + $this->applications->add($application); + $application->setIntern($this); + } + + return $this; + } + + public function removeApplication(InternApplication $application): static + { + if ($this->applications->removeElement($application)) { + // set the owning side to null (unless already changed) + if ($application->getIntern() === $this) { + $application->setIntern(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getFavorites(): Collection + { + return $this->favorites; + } + + public function addFavorite(InternFavorite $favorite): static + { + if (!$this->favorites->contains($favorite)) { + $this->favorites->add($favorite); + $favorite->setIntern($this); + } + + return $this; + } + + public function removeFavorite(InternFavorite $favorite): static + { + if ($this->favorites->removeElement($favorite)) { + // set the owning side to null (unless already changed) + if ($favorite->getIntern() === $this) { + $favorite->setIntern(null); + } + } return $this; } diff --git a/src/Entity/InternApplication.php b/src/Entity/InternApplication.php new file mode 100644 index 0000000..484a6ea --- /dev/null +++ b/src/Entity/InternApplication.php @@ -0,0 +1,66 @@ +id; + } + + public function getApplication(): ?Announcement + { + return $this->application; + } + + public function setApplication(?Announcement $application): static + { + $this->application = $application; + + return $this; + } + + public function getIntern(): ?Intern + { + return $this->intern; + } + + public function setIntern(?Intern $intern): static + { + $this->intern = $intern; + + return $this; + } + + public function getApplicationDate(): ?\DateTimeInterface + { + return $this->applicationDate; + } + + public function setApplicationDate(\DateTimeInterface $applicationDate): static + { + $this->applicationDate = $applicationDate; + + return $this; + } +} diff --git a/src/Entity/InternDegree.php b/src/Entity/InternDegree.php new file mode 100644 index 0000000..01be94b --- /dev/null +++ b/src/Entity/InternDegree.php @@ -0,0 +1,66 @@ +id; + } + + public function getDegree(): ?Degree + { + return $this->degree; + } + + public function setDegree(?Degree $degree): static + { + $this->degree = $degree; + + return $this; + } + + public function getIntern(): ?Intern + { + return $this->intern; + } + + public function setIntern(?Intern $intern): static + { + $this->intern = $intern; + + return $this; + } + + public function getGraduationDate(): ?\DateTimeInterface + { + return $this->graduationDate; + } + + public function setGraduationDate(\DateTimeInterface $graduationDate): static + { + $this->graduationDate = $graduationDate; + + return $this; + } +} diff --git a/src/Entity/InternFavorite.php b/src/Entity/InternFavorite.php new file mode 100644 index 0000000..8dd915b --- /dev/null +++ b/src/Entity/InternFavorite.php @@ -0,0 +1,50 @@ +id; + } + + public function getAnnouncement(): ?Announcement + { + return $this->announcement; + } + + public function setAnnouncement(?Announcement $announcement): static + { + $this->announcement = $announcement; + + return $this; + } + + public function getIntern(): ?Intern + { + return $this->intern; + } + + public function setIntern(?Intern $intern): static + { + $this->intern = $intern; + + return $this; + } +} diff --git a/src/Entity/InternSkill.php b/src/Entity/InternSkill.php new file mode 100644 index 0000000..89d8cfa --- /dev/null +++ b/src/Entity/InternSkill.php @@ -0,0 +1,50 @@ +id; + } + + public function getSkill(): ?Skill + { + return $this->skill; + } + + public function setSkill(?Skill $skill): static + { + $this->skill = $skill; + + return $this; + } + + public function getIntern(): ?Intern + { + return $this->intern; + } + + public function setIntern(?Intern $intern): static + { + $this->intern = $intern; + + return $this; + } +} diff --git a/src/Entity/Message.php b/src/Entity/Message.php new file mode 100644 index 0000000..b9e9969 --- /dev/null +++ b/src/Entity/Message.php @@ -0,0 +1,81 @@ +id; + } + + public function getSender(): ?UserApp + { + return $this->sender; + } + + public function setSender(?UserApp $sender): static + { + $this->sender = $sender; + + return $this; + } + + public function getReceiver(): ?UserApp + { + return $this->receiver; + } + + public function setReceiver(?UserApp $receiver): static + { + $this->receiver = $receiver; + + return $this; + } + + public function getContent(): ?string + { + return $this->content; + } + + public function setContent(string $content): static + { + $this->content = $content; + + return $this; + } + + public function getSendingDate(): ?\DateTimeInterface + { + return $this->sendingDate; + } + + public function setSendingDate(\DateTimeInterface $sendingDate): static + { + $this->sendingDate = $sendingDate; + + return $this; + } +} diff --git a/src/Entity/Skill.php b/src/Entity/Skill.php index 47bea20..7752cfe 100644 --- a/src/Entity/Skill.php +++ b/src/Entity/Skill.php @@ -19,9 +19,9 @@ class Skill private ?string $label = null; /** - * @var Collection + * @var Collection */ - #[ORM\ManyToMany(targetEntity: Intern::class, mappedBy: 'skills')] + #[ORM\OneToMany(targetEntity: InternSkill::class, mappedBy: 'skill')] private Collection $interns; public function __construct() @@ -47,27 +47,30 @@ class Skill } /** - * @return Collection + * @return Collection */ public function getInterns(): Collection { return $this->interns; } - public function addIntern(Intern $intern): static + public function addIntern(InternSkill $intern): static { if (!$this->interns->contains($intern)) { $this->interns->add($intern); - $intern->addSkill($this); + $intern->setSkill($this); } return $this; } - public function removeIntern(Intern $intern): static + public function removeIntern(InternSkill $intern): static { if ($this->interns->removeElement($intern)) { - $intern->removeSkill($this); + // set the owning side to null (unless already changed) + if ($intern->getSkill() === $this) { + $intern->setSkill(null); + } } return $this; diff --git a/src/Repository/DegreeRepository.php b/src/Repository/DegreeRepository.php new file mode 100644 index 0000000..474fbe7 --- /dev/null +++ b/src/Repository/DegreeRepository.php @@ -0,0 +1,43 @@ + + */ +class DegreeRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Degree::class); + } + + // /** + // * @return Degree[] Returns an array of Degree objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('d') + // ->andWhere('d.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('d.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Degree + // { + // return $this->createQueryBuilder('d') + // ->andWhere('d.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/InternApplicationRepository.php b/src/Repository/InternApplicationRepository.php new file mode 100644 index 0000000..b2957e1 --- /dev/null +++ b/src/Repository/InternApplicationRepository.php @@ -0,0 +1,43 @@ + + */ +class InternApplicationRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, InternApplication::class); + } + + // /** + // * @return InternApplication[] Returns an array of InternApplication objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('i') + // ->andWhere('i.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('i.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?InternApplication + // { + // return $this->createQueryBuilder('i') + // ->andWhere('i.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/InternDegreeRepository.php b/src/Repository/InternDegreeRepository.php new file mode 100644 index 0000000..7c7dafb --- /dev/null +++ b/src/Repository/InternDegreeRepository.php @@ -0,0 +1,43 @@ + + */ +class InternDegreeRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, InternDegree::class); + } + + // /** + // * @return InternDegree[] Returns an array of InternDegree objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('i') + // ->andWhere('i.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('i.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?InternDegree + // { + // return $this->createQueryBuilder('i') + // ->andWhere('i.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/InternFavoriteRepository.php b/src/Repository/InternFavoriteRepository.php new file mode 100644 index 0000000..ff5b296 --- /dev/null +++ b/src/Repository/InternFavoriteRepository.php @@ -0,0 +1,43 @@ + + */ +class InternFavoriteRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, InternFavorite::class); + } + + // /** + // * @return InternFavorite[] Returns an array of InternFavorite objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('i') + // ->andWhere('i.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('i.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?InternFavorite + // { + // return $this->createQueryBuilder('i') + // ->andWhere('i.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/InternSkillRepository.php b/src/Repository/InternSkillRepository.php new file mode 100644 index 0000000..fd0d1af --- /dev/null +++ b/src/Repository/InternSkillRepository.php @@ -0,0 +1,43 @@ + + */ +class InternSkillRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, InternSkill::class); + } + + // /** + // * @return InternSkill[] Returns an array of InternSkill objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('i') + // ->andWhere('i.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('i.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?InternSkill + // { + // return $this->createQueryBuilder('i') + // ->andWhere('i.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/MessageRepository.php b/src/Repository/MessageRepository.php new file mode 100644 index 0000000..e7f1849 --- /dev/null +++ b/src/Repository/MessageRepository.php @@ -0,0 +1,43 @@ + + */ +class MessageRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Message::class); + } + + // /** + // * @return Message[] Returns an array of Message objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('m') + // ->andWhere('m.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('m.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Message + // { + // return $this->createQueryBuilder('m') + // ->andWhere('m.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +}