<?phpnamespace App\Entity;use App\Repository\EngagementRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: EngagementRepository::class)]class Engagement{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\ManyToOne(inversedBy: 'engagements')] #[Assert\NotBlank (message:"Le champ ne peut pas être vide.")] private ?User $formateur = null; #[ORM\ManyToOne(inversedBy: 'engagements')] #[Assert\NotBlank (message:"Le champ ne peut pas être vide.")] private ?Module $module = null; #[ORM\ManyToOne(inversedBy: 'engagements')] #[Assert\NotBlank (message:"Le champ ne peut pas être vide.")] private ?Cycle $cycle = null; #[ORM\OneToMany(mappedBy: 'engagement', targetEntity: FactureFormateur::class)] private Collection $factureFormateurs; #[ORM\Column(length: 255)] private ?string $groupe = null; #[ORM\ManyToOne(inversedBy:'engagements')] #[ORM\JoinColumn(nullable: false)] private ?Session $session = null; #[ORM\OneToMany(mappedBy: 'engagement', targetEntity: Seance::class)] private Collection $seances; public function __construct() { $this->factureFormateurs = new ArrayCollection(); $this->seances = new ArrayCollection(); } public function __toString() { return 'Session: ' . $this->getSession()->getLibele() . ' - Cycle: ' . $this->getCycle()->getLibele() . ' - Formateur:' . $this->getFormateur()->getUserIdentifier() . ' - Module:' . $this->getModule()->getLibele() . ' - Groupe:' . $this->getGroupe(); } public function getId(): ?int { return $this->id; } public function getFormateur(): ?User { return $this->formateur; } public function setFormateur(?User $formateur): self { $this->formateur = $formateur; return $this; } public function getModule(): ?Module { return $this->module; } public function setModule(?Module $module): self { $this->module = $module; return $this; } public function getCycle(): ?Cycle { return $this->cycle; } public function setCycle(?Cycle $cycle): self { $this->cycle = $cycle; return $this; } /** * @return Collection<int, FactureFormateur> */ public function getFactureFormateurs(): Collection { return $this->factureFormateurs; } public function addFactureFormateur( FactureFormateur $factureFormateur ): self { if (!$this->factureFormateurs->contains($factureFormateur)) { $this->factureFormateurs->add($factureFormateur); $factureFormateur->setEngagement($this); } return $this; } public function removeFactureFormateur( FactureFormateur $factureFormateur ): self { if ($this->factureFormateurs->removeElement($factureFormateur)) { // set the owning side to null (unless already changed) if ($factureFormateur->getEngagement() === $this) { $factureFormateur->setEngagement(null); } } return $this; } public function getGroupe(): ?string { return $this->groupe; } public function setGroupe(?string $groupe): self { $this->groupe = $groupe; return $this; } public function getSession(): ?Session { return $this->session; } public function setSession(?Session $session): self { $this->session = $session; return $this; } /** * @return Collection<int, Seance> */ public function getSeances(): Collection { return $this->seances; } public function addSeance(Seance $seance): self { if (!$this->seances->contains($seance)) { $this->seances->add($seance); $seance->setEngagement($this); } return $this; } public function removeSeance(Seance $seance): self { if ($this->seances->removeElement($seance)) { // set the owning side to null (unless already changed) if ($seance->getEngagement() === $this) { $seance->setEngagement(null); } } return $this; }}