Search internship + Merci Mr Boussarie
This commit is contained in:
parent
5834b02fdc
commit
19c4dd08e1
@ -20,32 +20,38 @@ final class AnnouncementController extends AbstractController
|
||||
$user = $this->getUser();
|
||||
$announcements = [];
|
||||
|
||||
// Récupérer les paramètres de recherche
|
||||
$companyName = $request->query->get('company_name');
|
||||
$location = $request->query->get('location');
|
||||
$category = $request->query->get('category');
|
||||
|
||||
if (in_array('ROLE_ADMIN', $user->getRoles())) {
|
||||
$showNonValidated = $request->query->get('show_non_validated');
|
||||
|
||||
if ($showNonValidated) {
|
||||
$announcements = $announcementRepository->findBy(['status' => 'notVerified']);
|
||||
}
|
||||
if (!$showNonValidated){
|
||||
} else {
|
||||
$announcements = $announcementRepository->findAll();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (in_array('ROLE_EMPLOYEE', $user->getRoles())) {
|
||||
$company = $user->getCompany();
|
||||
|
||||
if ($company)
|
||||
{
|
||||
if ($company) {
|
||||
$announcements = $announcementRepository->findBy(['company' => $company]);
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array('ROLE_INTERN', $user->getRoles()))
|
||||
{
|
||||
if (in_array('ROLE_INTERN', $user->getRoles())) {
|
||||
$announcements = $announcementRepository->findBy(['status' => 'Verified']);
|
||||
}
|
||||
|
||||
// Filtrer les annonces en fonction des critères de recherche
|
||||
if ($companyName || $location || $category) {
|
||||
$announcements = $announcementRepository->searchAnnouncements($companyName, $location, $category);
|
||||
}
|
||||
|
||||
return $this->render('announcement/index.html.twig', [
|
||||
'announcements' => $announcements,
|
||||
'showNonValidated' => $request->query->get('show_non_validated', false),
|
||||
|
@ -16,6 +16,28 @@ class AnnouncementRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, Announcement::class);
|
||||
}
|
||||
|
||||
public function searchAnnouncements(?string $companyName, ?string $location, ?string $category): array
|
||||
{
|
||||
$queryBuilder = $this->createQueryBuilder('a')->InnerJoin('a.company', 'c');
|
||||
|
||||
if ($companyName) {
|
||||
$queryBuilder->andWhere('c.name LIKE :companyName')
|
||||
->setParameter('companyName', '%' . $companyName . '%');
|
||||
}
|
||||
|
||||
if ($location) {
|
||||
$queryBuilder->andWhere('c.address LIKE :location')
|
||||
->setParameter('location', '%' . $location . '%');
|
||||
}
|
||||
|
||||
if ($category) {
|
||||
$queryBuilder->andWhere('a.title LIKE :category OR a.description LIKE :category')
|
||||
->setParameter('category', '%' . $category . '%');
|
||||
}
|
||||
|
||||
return $queryBuilder->getQuery()->getResult();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Announcement[] Returns an array of Announcement objects
|
||||
// */
|
||||
|
@ -36,6 +36,21 @@
|
||||
|
||||
<!-- Liste des annonces -->
|
||||
<div class="max-w-4xl mx-auto">
|
||||
<div class="bg-white rounded-lg shadow-lg p-6 inline-block text-center my-10">
|
||||
<form method="get" class="flex flex-col md:flex-row space-y-4 md:space-y-0 md:space-x-4 text-black">
|
||||
<label>
|
||||
<input class="border border-gray-300 rounded py-2 px-4 w-full md:w-auto" placeholder="Rechercher par entreprise" type="text" name="company_name" value="{{ app.request.query.get('company_name') }}"/>
|
||||
</label>
|
||||
<label>
|
||||
<input class="border border-gray-300 rounded py-2 px-4 w-full md:w-auto" placeholder="Rechercher par lieu" type="text" name="location" value="{{ app.request.query.get('location') }}"/>
|
||||
</label>
|
||||
<label>
|
||||
<input class="border border-gray-300 rounded py-2 px-4 w-full md:w-auto" placeholder="Autre recherche" type="text" name="category" value="{{ app.request.query.get('category') }}"/>
|
||||
</label>
|
||||
<button type="submit" class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-6 rounded">Rechercher</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% for announcement in announcements %}
|
||||
<div class="bg-white p-6 rounded-lg shadow mb-4 relative">
|
||||
<!-- Statut en haut à droite -->
|
||||
|
@ -11,21 +11,6 @@
|
||||
<div class="container mx-auto text-center text-white">
|
||||
<h1 class="text-4xl md:text-5xl font-bold mb-4">Trouvez votre stage de rêve !</h1>
|
||||
<p class="text-lg mb-8">Connectez les talents aux opportunités : votre clé vers le succès professionnel</p>
|
||||
<div class="bg-white rounded-lg shadow-lg p-6 inline-block">
|
||||
<div class="flex flex-col md:flex-row space-y-4 md:space-y-0 md:space-x-4">
|
||||
<label>
|
||||
<input class="border border-gray-300 rounded py-2 px-4 w-full md:w-auto" placeholder="Nom de l'entreprise" type="text"/>
|
||||
</label>
|
||||
<label>
|
||||
<input class="border border-gray-300 rounded py-2 px-4 w-full md:w-auto" placeholder="Indiquez un endroit" type="text"/>
|
||||
</label>
|
||||
<label>
|
||||
<input class="border border-gray-300 rounded py-2 px-4 w-full md:w-auto" placeholder="Sélectionnez une catégorie" type="text"/>
|
||||
</label>
|
||||
<button class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-6 rounded">Trouvez un stage</button>
|
||||
</div>
|
||||
<p class="text-black"> la recherche n'est pas encore implémenté </p>
|
||||
</div>
|
||||
<div class="flex justify-center space-x-8 mt-8">
|
||||
<div class="text-center">
|
||||
<i class="fas fa-briefcase text-2xl"></i>
|
||||
|
Loading…
x
Reference in New Issue
Block a user