tqt encore ++
This commit is contained in:
parent
e083dc1cec
commit
9ec6a67a92
@ -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]);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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)
|
||||
;
|
||||
}
|
||||
|
@ -13,7 +13,8 @@
|
||||
<h2> {{ ann.title }} </h2>
|
||||
<h3> {{ ann.company.name }} </h3>
|
||||
<p> {{ ann.description }} </p>
|
||||
------------------------------
|
||||
|
||||
<p> {{ ann.creationDate }} </p>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user