You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
2.5 KiB
PHP

<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\GroupRepository")
*/
class Group
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Member", mappedBy="id_group", orphanRemoval=true)
*/
private $members;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Wish", mappedBy="target", orphanRemoval=true)
*/
private $wishes;
public function __construct()
{
$this->members = new ArrayCollection();
$this->wishes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection|Member[]
*/
public function getMembers(): Collection
{
return $this->members;
}
public function addMember(Member $member): self
{
if (!$this->members->contains($member)) {
$this->members[] = $member;
$member->setGroup($this);
}
return $this;
}
public function removeMember(Member $member): self
{
if ($this->members->contains($member)) {
$this->members->removeElement($member);
// set the owning side to null (unless already changed)
if ($member->getGroup() === $this) {
$member->setGroup(null);
}
}
return $this;
}
/**
* @return Collection|Wish[]
*/
public function getWishes(): Collection
{
return $this->wishes;
}
public function addWish(Wish $wish): self
{
if (!$this->wishes->contains($wish)) {
$this->wishes[] = $wish;
$wish->setTarget($this);
}
return $this;
}
public function removeWish(Wish $wish): self
{
if ($this->wishes->contains($wish)) {
$this->wishes->removeElement($wish);
// set the owning side to null (unless already changed)
if ($wish->getTarget() === $this) {
$wish->setTarget(null);
}
}
return $this;
}
}