diff --git a/src/Controller/AnnouncementController.php b/src/Controller/AnnouncementController.php index 150595b..9ca78fc 100644 --- a/src/Controller/AnnouncementController.php +++ b/src/Controller/AnnouncementController.php @@ -3,7 +3,6 @@ namespace App\Controller; use App\Entity\Announcement; -use App\Entity\InternApplication; use App\Form\AnnouncementType; use App\Repository\AnnouncementRepository; use Doctrine\ORM\EntityManagerInterface; @@ -66,9 +65,6 @@ class AnnouncementController extends AbstractController { $this->entityManager->persist($announcement); $this->entityManager->flush(); - - $this->addFlash('success', 'Annonce modifiéé avec succès.'); - return $this->redirectToRoute('app_announcement_list'); } return $this->render('announcement/add.html.twig', [ @@ -85,39 +81,4 @@ class AnnouncementController extends AbstractController return $this->redirectToRoute('app_announcement_list'); } - - #[Route('/apply/{id}', name: '_apply')] - public function applyToAnnouncement(int $id): Response - { - - $announcement = $this->announcementRepository->find($id); - - $user = $this->getUser(); - - $existingCandidature = $this->entityManager->getRepository(InternApplication::class)->findOneBy([ - 'intern' => $user, - 'announcement' => $announcement - ]); - - if($existingCandidature) { - $this->addFlash('error', 'Vous avez déjà postulé à cette annonce.'); - return $this->redirectToRoute('app_announcement_list'); - } - $application = new InternApplication(); - $application->setIntern($user); - $application->setIntern($announcement); - $application->setApplicationDate(new \DateTime()); - - $this->entityManager->persist($application); - $this->entityManager->flush(); - - $this->addFlash('success', 'Votre candidature a été envoyée avec succès.'); - return $this->redirectToRoute('annonce_list', ['id' => $announcement->getId()]); - } - - #[Route('/filterByCompany', name: '_filterByCompany')] - public function filterByCompany(int $id): Response - { - return $this->redirectToRoute('annonce_list', ['id' => $id]); - } } diff --git a/src/Entity/Announcement.php b/src/Entity/Announcement.php index 5cf1c55..94cf1a6 100644 --- a/src/Entity/Announcement.php +++ b/src/Entity/Announcement.php @@ -5,6 +5,7 @@ namespace App\Entity; use App\Repository\AnnouncementRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: AnnouncementRepository::class)] @@ -30,16 +31,19 @@ class Announcement private ?Status $status = null; /** - * @var Collection + * @var ?Collection */ #[ORM\OneToMany(targetEntity: InternApplication::class, mappedBy: 'application')] - private Collection $applicants; + private ?Collection $applicants; /** - * @var Collection + * @var ?Collection */ #[ORM\OneToMany(targetEntity: InternFavorite::class, mappedBy: 'announcement')] - private Collection $favoritesInterns; + private ?Collection $favoritesInterns; + + #[ORM\Column(type: Types::DATE_MUTABLE)] + private ?\DateTimeInterface $creationDate = null; public function __construct() { @@ -159,4 +163,16 @@ class Announcement return $this; } + + public function getCreationDate(): ?\DateTimeInterface + { + return $this->creationDate; + } + + public function setCreationDate(\DateTimeInterface $creationDate): static + { + $this->creationDate = $creationDate; + + return $this; + } } diff --git a/src/Entity/Obtaining.php b/src/Entity/Obtaining.php deleted file mode 100644 index cecb3c1..0000000 --- a/src/Entity/Obtaining.php +++ /dev/null @@ -1,36 +0,0 @@ -id; - } - - public function getDate(): ?\DateTimeInterface - { - return $this->date; - } - - public function setDate(\DateTimeInterface $date): static - { - $this->date = $date; - - return $this; - } -} diff --git a/src/Form/AnnouncementType.php b/src/Form/AnnouncementType.php index 21a844d..ef1255f 100644 --- a/src/Form/AnnouncementType.php +++ b/src/Form/AnnouncementType.php @@ -22,6 +22,10 @@ class AnnouncementType extends AbstractType 'class' => Company::class, 'choice_label' => 'id', ]) + ->add('status', EntityType::class, [ + 'class' => Status::class, + 'choice_label' => 'id', + ]) ->add('submit', SubmitType::class) ; } diff --git a/templates/announcement/list.html.twig b/templates/announcement/list.html.twig index 91cfb8d..d1d3c02 100644 --- a/templates/announcement/list.html.twig +++ b/templates/announcement/list.html.twig @@ -13,7 +13,8 @@

{{ ann.title }}

{{ ann.company.name }}

{{ ann.description }}

- ------------------------------ + +

{{ ann.creationDate }}

{% endfor %}