Skip to content
Snippets Groups Projects
Commit 12212c0e authored by SAVERGNE Yvan's avatar SAVERGNE Yvan
Browse files

Merge branch 'master' into 'main'

ajout d'un rond rouge sur les notifs

See merge request !68
parents f1cf03a6 5dde82e6
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 ...@@ -21,7 +21,7 @@ class NotificationsController extends AbstractController
public function index(): Response public function index(): Response
{ {
$entityManager = $this->doctrine->getManager(); $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', [ return $this->render('notifications/index.html.twig', [
'notifs' => $notifs 'notifs' => $notifs
]); ]);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Entity; namespace App\Entity;
use App\Repository\UtilisateurRepository; use App\Repository\UtilisateurRepository;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
...@@ -75,6 +76,9 @@ class Utilisateur extends Personne ...@@ -75,6 +76,9 @@ class Utilisateur extends Personne
#[ORM\ManyToMany(targetEntity: Prestations::class, inversedBy: 'utilisateurs_aimant')] #[ORM\ManyToMany(targetEntity: Prestations::class, inversedBy: 'utilisateurs_aimant')]
private Collection $prestations_aimees; private Collection $prestations_aimees;
#[ORM\OneToMany(mappedBy: 'user_id', targetEntity: Notification::class, orphanRemoval: true)]
private Collection $notifs;
public function __construct() public function __construct()
{ {
$this->inscriptions = new ArrayCollection(); $this->inscriptions = new ArrayCollection();
...@@ -84,6 +88,7 @@ class Utilisateur extends Personne ...@@ -84,6 +88,7 @@ class Utilisateur extends Personne
$this->prestations_proprietaire = new ArrayCollection(); $this->prestations_proprietaire = new ArrayCollection();
$this->litiges = new ArrayCollection(); $this->litiges = new ArrayCollection();
$this->prestations_aimees = new ArrayCollection(); $this->prestations_aimees = new ArrayCollection();
$this->notifs = new ArrayCollection();
} }
public function getNbFlorains(): ?int public function getNbFlorains(): ?int
...@@ -500,4 +505,15 @@ class Utilisateur extends Personne ...@@ -500,4 +505,15 @@ class Utilisateur extends Personne
if (!$this->prestations_aimees) return false; if (!$this->prestations_aimees) return false;
return $this->prestations_aimees->contains($prestation); 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 @@ ...@@ -9,7 +9,12 @@
{% endif %} {% endif %}
</div> </div>
<p>{{ app.user.login }}</p> <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> <a href="{{ path("app_modif_user")}}" ><img src={{asset('/img/bonhomme.png')}} alt="logo profil" width="50px"/></a>
{% if not is_granted('ROLE_ADMIN') %} {% if not is_granted('ROLE_ADMIN') %}
<p>Solde: {{ app.user.getNbFlorains() }}</p> <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