tqt encore ++

This commit is contained in:
Romain 2024-11-11 16:00:51 +01:00 committed by bourgoino
parent e083dc1cec
commit 9ec6a67a92
5 changed files with 26 additions and 80 deletions

View File

@ -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]);
}
}

View File

@ -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<int, InternApplication>
* @var ?Collection<int, InternApplication>
*/
#[ORM\OneToMany(targetEntity: InternApplication::class, mappedBy: 'application')]
private Collection $applicants;
private ?Collection $applicants;
/**
* @var Collection<int, InternFavorite>
* @var ?Collection<int, InternFavorite>
*/
#[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;
}
}

View File

@ -1,36 +0,0 @@
<?php
namespace App\Entity;
use App\Repository\ObtainingRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ObtainingRepository::class)]
class Obtaining
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
private ?\DateTimeInterface $date = null;
public function getId(): ?int
{
return $this->id;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): static
{
$this->date = $date;
return $this;
}
}

View File

@ -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)
;
}

View File

@ -13,7 +13,8 @@
<h2> {{ ann.title }} </h2>
<h3> {{ ann.company.name }} </h3>
<p> {{ ann.description }} </p>
------------------------------
<p> {{ ann.creationDate }} </p>
{% endfor %}