diff --git a/src/Entity/Task.php b/src/Entity/Task.php index 49c9b99..63563c0 100644 --- a/src/Entity/Task.php +++ b/src/Entity/Task.php @@ -71,7 +71,7 @@ class Task #[Gedmo\Timestampable(on: 'create')] private ?\DateTimeImmutable $createdAt = null; - #[ORM\ManyToOne] + #[ORM\ManyToOne(inversedBy: 'lockedTasks')] private ?User $lockedBy = null; #[ORM\Column(nullable: true)] diff --git a/src/Entity/User.php b/src/Entity/User.php index 30d33eb..2473f6b 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -43,10 +43,17 @@ class User implements UserInterface #[ORM\OneToMany(targetEntity: Task::class, mappedBy: 'createdBy', orphanRemoval: true)] private Collection $tasks; + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: Task::class, mappedBy: 'lockedBy', orphanRemoval: true)] + private Collection $lockedTasks; + public function __construct() { $this->projects = new ArrayCollection(); $this->tasks = new ArrayCollection(); + $this->lockedTasks = new ArrayCollection(); } public function getId(): ?int @@ -180,4 +187,13 @@ class User implements UserInterface return $this; } + + /** + * @return Collection + */ + public function getLockedTasks(): Collection + { + return $this->lockedTasks; + } + } diff --git a/templates/_header.html.twig b/templates/_header.html.twig index 67bebbb..e2d25f0 100644 --- a/templates/_header.html.twig +++ b/templates/_header.html.twig @@ -13,6 +13,23 @@ {% endfor %} {% if is_granted('IS_AUTHENTICATED_FULLY') %} + {% if app.user.lockedTasks is not empty %} + + {% endif %}