Skip to content
Snippets Groups Projects
Commit 5dde82e6 authored by YvanSv's avatar YvanSv
Browse files

ajout d'un rond rouge sur les notifs

parent 780f3cb5
No related branches found
No related tags found
1 merge request!68ajout d'un rond rouge sur les notifs
public/img/notifs_non_lues.png

21.6 KiB

......@@ -21,7 +21,7 @@ class NotificationsController extends AbstractController
public function index(): Response
{
$entityManager = $this->doctrine->getManager();
$notifs = $entityManager->getRepository(Notification::class)->findBy(['user_id' => $this->getUser()]);;
$notifs = $entityManager->getRepository(Notification::class)->findBy(['user_id' => $this->getUser()]);
return $this->render('notifications/index.html.twig', [
'notifs' => $notifs
]);
......
......@@ -3,6 +3,7 @@
namespace App\Entity;
use App\Repository\UtilisateurRepository;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
......@@ -75,6 +76,9 @@ class Utilisateur extends Personne
#[ORM\ManyToMany(targetEntity: Prestations::class, inversedBy: 'utilisateurs_aimant')]
private Collection $prestations_aimees;
#[ORM\OneToMany(mappedBy: 'user_id', targetEntity: Notification::class, orphanRemoval: true)]
private Collection $notifs;
public function __construct()
{
$this->inscriptions = new ArrayCollection();
......@@ -84,6 +88,7 @@ class Utilisateur extends Personne
$this->prestations_proprietaire = new ArrayCollection();
$this->litiges = new ArrayCollection();
$this->prestations_aimees = new ArrayCollection();
$this->notifs = new ArrayCollection();
}
public function getNbFlorains(): ?int
......@@ -500,4 +505,15 @@ class Utilisateur extends Personne
if (!$this->prestations_aimees) return false;
return $this->prestations_aimees->contains($prestation);
}
/**
* @return Collection<int, Notification>
*/
public function getNotifs(): Collection {
return $this->notifs;
}
public function hasNotifs() : bool {
return count($this->notifs) > 0;
}
}
......@@ -9,7 +9,12 @@
{% endif %}
</div>
<p>{{ app.user.login }}</p>
<a href="{{ path("app_notifications")}}"><img src={{asset('/img/notifs.png')}} alt="logo profil" width="35px"/></a>
{% if app.user.notifs|length > 0 %}
<a href="{{ path("app_notifications")}}"><img src={{asset('/img/notifs_non_lues.png')}} alt="logo profil" width="35px"/></a>
{% else %}
<a href="{{ path("app_notifications")}}"><img src={{asset('/img/notifs.png')}} alt="logo profil" width="35px"/></a>
{% endif %}
<a href="{{ path("app_modif_user")}}" ><img src={{asset('/img/bonhomme.png')}} alt="logo profil" width="50px"/></a>
{% if not is_granted('ROLE_ADMIN') %}
<p>Solde: {{ app.user.getNbFlorains() }}</p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment