relation ManyToMany done
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\SortieRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
@@ -37,9 +39,9 @@ class Sortie
|
||||
#[ORM\JoinColumn(name: 'site_id', referencedColumnName: 'id_site', nullable: false)]
|
||||
private ?Site $site = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Participant::class, inversedBy: 'sorties')]
|
||||
#[ORM\JoinColumn(name: 'participant_id', referencedColumnName: 'id_participant', nullable: false)]
|
||||
private ?Participant $participant = null;
|
||||
#[ORM\ManyToOne(targetEntity: Participant::class, inversedBy: 'sortiesOrganisateur')]
|
||||
#[ORM\JoinColumn(name: 'organisateur_id', referencedColumnName: 'id_participant', nullable: false)]
|
||||
private ?Participant $organisateur = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Lieu::class, inversedBy: 'sorties')]
|
||||
#[ORM\JoinColumn(name: 'lieu_id', referencedColumnName: 'id_lieu', nullable: false)]
|
||||
@@ -49,6 +51,17 @@ class Sortie
|
||||
#[ORM\JoinColumn(name: 'etat_id', referencedColumnName: 'id_etat', nullable: false)]
|
||||
private ?Etat $etat = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Participant>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Participant::class, mappedBy: 'sortiesParticipants')]
|
||||
private Collection $participants;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->participants = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getIdSortie(): ?string
|
||||
{
|
||||
return $this->idSortie;
|
||||
@@ -138,14 +151,14 @@ class Sortie
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParticipant(): ?Participant
|
||||
public function getOrganisateur(): ?Participant
|
||||
{
|
||||
return $this->participant;
|
||||
return $this->organisateur;
|
||||
}
|
||||
|
||||
public function setParticipant(?Participant $participant): self
|
||||
public function setOrganisateur(?Participant $organisateur): self
|
||||
{
|
||||
$this->participant = $participant;
|
||||
$this->organisateur = $organisateur;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -173,4 +186,28 @@ class Sortie
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Participant>
|
||||
*/
|
||||
public function getParticipants(): Collection
|
||||
{
|
||||
return $this->participants;
|
||||
}
|
||||
|
||||
public function addParticipant(Participant $participant): static
|
||||
{
|
||||
if (!$this->participants->contains($participant)) {
|
||||
$this->participants->add($participant);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeParticipant(Participant $participant): static
|
||||
{
|
||||
$this->participants->removeElement($participant);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user