<?phpnamespace App\Entity;use App\Repository\GroupSuggestionRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=GroupSuggestionRepository::class) */class GroupSuggestion{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="datetime") */ private $cretedAt; /** * @ORM\ManyToOne(targetEntity=User::class, inversedBy="groupSuggestions") * @ORM\JoinColumn(nullable=false) */ private $user; /** * @ORM\OneToMany(targetEntity=Suggestion::class, mappedBy="groupsuggestion") * @ORM\JoinColumn(nullable=false, onDelete="CASCADE") */ private $suggestions; /** * @ORM\ManyToOne(targetEntity=PropositionStatus::class, inversedBy="groupSuggestions") * @ORM\JoinColumn(nullable=false, onDelete="CASCADE") */ private $status; public function __construct() { $this->suggestions = new ArrayCollection(); $this->cretedAt = new \DateTime(); } public function getId(): ?int { return $this->id; } public function getCretedAt(): ?\DateTimeInterface { return $this->cretedAt; } public function setCretedAt(\DateTimeInterface $cretedAt): self { $this->cretedAt = $cretedAt; return $this; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): self { $this->user = $user; return $this; } /** * @return Collection<int, Suggestion> */ public function getSuggestions(): Collection { return $this->suggestions; } public function addSuggestion(Suggestion $suggestion): self { if (!$this->suggestions->contains($suggestion)) { $this->suggestions[] = $suggestion; $suggestion->setGroupsuggestion($this); } return $this; } public function removeSuggestion(Suggestion $suggestion): self { if ($this->suggestions->removeElement($suggestion)) { // set the owning side to null (unless already changed) if ($suggestion->getGroupsuggestion() === $this) { $suggestion->setGroupsuggestion(null); } } return $this; } public function getStatus(): ?PropositionStatus { return $this->status; } public function setStatus(?PropositionStatus $status): self { $this->status = $status; return $this; } public function getNumberPrescripteur() { $count = 0; foreach ($this->suggestions as $suggestion) { if ($suggestion->getProposition()->getUser() != null) { $count++; } } return $count; }}