ajout diplome et message + gestion des relations

This commit is contained in:
Romain 2024-11-10 15:41:01 +01:00 committed by barillote
parent 071fcb41b4
commit a8b80273a7
15 changed files with 807 additions and 96 deletions

View File

@ -30,21 +30,21 @@ class Announcement
private ?Status $status = null; private ?Status $status = null;
/** /**
* @var Collection<int, Intern> * @var Collection<int, InternApplication>
*/ */
#[ORM\ManyToMany(targetEntity: Intern::class, mappedBy: 'favorites')] #[ORM\OneToMany(targetEntity: InternApplication::class, mappedBy: 'application')]
private Collection $internsfav; private Collection $applicants;
/** /**
* @var Collection<int, Intern> * @var Collection<int, InternFavorite>
*/ */
#[ORM\ManyToMany(targetEntity: Intern::class, mappedBy: 'applications')] #[ORM\OneToMany(targetEntity: InternFavorite::class, mappedBy: 'announcement')]
private Collection $applicants; private Collection $favoritesInterns;
public function __construct() public function __construct()
{ {
$this->internsfav = new ArrayCollection();
$this->applicants = new ArrayCollection(); $this->applicants = new ArrayCollection();
$this->favoritesInterns = new ArrayCollection();
} }
public function getId(): ?int public function getId(): ?int
@ -101,54 +101,60 @@ class Announcement
} }
/** /**
* @return Collection<int, Intern> * @return Collection<int, InternApplication>
*/
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<int, Intern>
*/ */
public function getApplicants(): Collection public function getApplicants(): Collection
{ {
return $this->applicants; return $this->applicants;
} }
public function addApplicant(Intern $applicant): static public function addApplicants(InternApplication $applicants): static
{ {
if (!$this->applicants->contains($applicant)) { if (!$this->applicants->contains($applicants)) {
$this->applicants->add($applicant); $this->applicants->add($applicants);
$applicant->addApplication($this); $applicants->setApplication($this);
} }
return $this; return $this;
} }
public function removeApplicant(Intern $applicant): static public function removeApplicants(InternApplication $applicants): static
{ {
if ($this->applicants->removeElement($applicant)) { if ($this->applicants->removeElement($applicants)) {
$applicant->removeApplication($this); // set the owning side to null (unless already changed)
if ($applicants->getApplication() === $this) {
$applicants->setApplication(null);
}
}
return $this;
}
/**
* @return Collection<int, InternFavorite>
*/
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; return $this;

78
src/Entity/Degree.php Normal file
View File

@ -0,0 +1,78 @@
<?php
namespace App\Entity;
use App\Repository\DegreeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: DegreeRepository::class)]
class Degree
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $label = null;
/**
* @var Collection<int, InternDegree>
*/
#[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<int, InternDegree>
*/
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;
}
}

View File

@ -19,30 +19,35 @@ class Intern extends UserApp
private ?string $resume = null; private ?string $resume = null;
/** /**
* @var Collection<int, Announcement> * @var Collection<int, InternDegree>
*/ */
#[ORM\ManyToMany(targetEntity: Announcement::class, inversedBy: 'interns')] #[ORM\OneToMany(targetEntity: InternDegree::class, mappedBy: 'intern')]
#[ORM\JoinTable(name: 'favorites')] private Collection $degrees;
private Collection $favorites;
/** /**
* @var Collection<int, Announcement> * @var Collection<int, InternSkill>
*/ */
#[ORM\ManyToMany(targetEntity: Announcement::class, inversedBy: 'applicants')] #[ORM\OneToMany(targetEntity: InternSkill::class, mappedBy: 'intern')]
#[ORM\JoinTable(name: 'applications')] private Collection $skills;
/**
* @var Collection<int, InternApplication>
*/
#[ORM\OneToMany(targetEntity: InternApplication::class, mappedBy: 'intern')]
private Collection $applications; private Collection $applications;
/** /**
* @var Collection<int, Skill> * @var Collection<int, InternFavorite>
*/ */
#[ORM\ManyToMany(targetEntity: Skill::class, inversedBy: 'interns')] #[ORM\OneToMany(targetEntity: InternFavorite::class, mappedBy: 'intern')]
private Collection $skills; private Collection $favorites;
public function __construct() public function __construct()
{ {
$this->favorites = new ArrayCollection(); $this->degrees = new ArrayCollection();
$this->applications = new ArrayCollection();
$this->skills = new ArrayCollection(); $this->skills = new ArrayCollection();
$this->applications = new ArrayCollection();
$this->favorites = new ArrayCollection();
} }
public function getCoverLetter(): ?string public function getCoverLetter(): ?string
@ -70,73 +75,121 @@ class Intern extends UserApp
} }
/** /**
* @return Collection<int, Announcement> * @return Collection<int, InternDegree>
*/ */
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)) { if (!$this->degrees->contains($degree)) {
$this->favorites->add($favorite); $this->degrees->add($degree);
$degree->setIntern($this);
} }
return $this; return $this;
} }
public function removeFavorite(Announcement $favorite): static public function removeDegree(InternDegree $degree): static
{ {
$this->favorites->removeElement($favorite); if ($this->degrees->removeElement($degree)) {
// set the owning side to null (unless already changed)
if ($degree->getIntern() === $this) {
$degree->setIntern(null);
}
}
return $this; return $this;
} }
/** /**
* @return Collection<int, Announcement> * @return Collection<int, InternSkill>
*/
public function getApplications(): Collection
{
return $this->applications;
}
public function addApplication(Announcement $application): static
{
if (!$this->applications->contains($application)) {
$this->applications->add($application);
}
return $this;
}
public function removeApplication(Announcement $application): static
{
$this->applications->removeElement($application);
return $this;
}
/**
* @return Collection<int, Skill>
*/ */
public function getSkills(): Collection public function getSkills(): Collection
{ {
return $this->skills; return $this->skills;
} }
public function addSkill(Skill $skill): static public function addSkill(InternSkill $skill): static
{ {
if (!$this->skills->contains($skill)) { if (!$this->skills->contains($skill)) {
$this->skills->add($skill); $this->skills->add($skill);
$skill->setIntern($this);
} }
return $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<int, InternApplication>
*/
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<int, InternFavorite>
*/
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; return $this;
} }

View File

@ -0,0 +1,66 @@
<?php
namespace App\Entity;
use App\Repository\InternApplicationRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: InternApplicationRepository::class)]
class InternApplication
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'applicants')]
private ?Announcement $application = null;
#[ORM\ManyToOne(inversedBy: 'applications')]
private ?Intern $intern = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
private ?\DateTimeInterface $applicationDate = null;
public function getId(): ?int
{
return $this->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;
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Entity;
use App\Repository\InternDegreeRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: InternDegreeRepository::class)]
class InternDegree
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'interns')]
private ?Degree $degree = null;
#[ORM\ManyToOne(inversedBy: 'degrees')]
private ?Intern $intern = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
private ?\DateTimeInterface $graduationDate = null;
public function getId(): ?int
{
return $this->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;
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace App\Entity;
use App\Repository\InternFavoriteRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: InternFavoriteRepository::class)]
class InternFavorite
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'favoritesInterns')]
private ?Announcement $announcement = null;
#[ORM\ManyToOne(inversedBy: 'favorites')]
private ?Intern $intern = null;
public function getId(): ?int
{
return $this->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;
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace App\Entity;
use App\Repository\InternSkillRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: InternSkillRepository::class)]
class InternSkill
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'interns')]
private ?Skill $skill = null;
#[ORM\ManyToOne(inversedBy: 'skills')]
private ?Intern $intern = null;
public function getId(): ?int
{
return $this->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;
}
}

81
src/Entity/Message.php Normal file
View File

@ -0,0 +1,81 @@
<?php
namespace App\Entity;
use App\Repository\MessageRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: MessageRepository::class)]
class Message
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne]
private ?UserApp $sender = null;
#[ORM\ManyToOne]
private ?UserApp $receiver = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $content = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $sendingDate = null;
public function getId(): ?int
{
return $this->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;
}
}

View File

@ -19,9 +19,9 @@ class Skill
private ?string $label = null; private ?string $label = null;
/** /**
* @var Collection<int, Intern> * @var Collection<int, InternSkill>
*/ */
#[ORM\ManyToMany(targetEntity: Intern::class, mappedBy: 'skills')] #[ORM\OneToMany(targetEntity: InternSkill::class, mappedBy: 'skill')]
private Collection $interns; private Collection $interns;
public function __construct() public function __construct()
@ -47,27 +47,30 @@ class Skill
} }
/** /**
* @return Collection<int, Intern> * @return Collection<int, InternSkill>
*/ */
public function getInterns(): Collection public function getInterns(): Collection
{ {
return $this->interns; return $this->interns;
} }
public function addIntern(Intern $intern): static public function addIntern(InternSkill $intern): static
{ {
if (!$this->interns->contains($intern)) { if (!$this->interns->contains($intern)) {
$this->interns->add($intern); $this->interns->add($intern);
$intern->addSkill($this); $intern->setSkill($this);
} }
return $this; return $this;
} }
public function removeIntern(Intern $intern): static public function removeIntern(InternSkill $intern): static
{ {
if ($this->interns->removeElement($intern)) { 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; return $this;

View File

@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\Degree;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Degree>
*/
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()
// ;
// }
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\InternApplication;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<InternApplication>
*/
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()
// ;
// }
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\InternDegree;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<InternDegree>
*/
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()
// ;
// }
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\InternFavorite;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<InternFavorite>
*/
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()
// ;
// }
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\InternSkill;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<InternSkill>
*/
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()
// ;
// }
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\Message;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Message>
*/
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()
// ;
// }
}