| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- <?php
- namespace App\Entity;
- use App\Repository\PartyRepository;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\DBAL\Types\Types;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Bridge\Doctrine\Types\UuidType;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- use Symfony\Component\Uid\Uuid;
- #[ORM\Entity(repositoryClass: PartyRepository::class)]
- class Party
- {
- #[ORM\Id]
- #[ORM\Column(type: UuidType::NAME, nullable: true)]
- #[ORM\GeneratedValue(strategy: 'CUSTOM')]
- #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
- private ?Uuid $id = null;
- #[ORM\ManyToOne(inversedBy: 'parties')]
- private ?Gamemaster $gamemaster = null;
- #[ORM\ManyToOne(inversedBy: 'parties')]
- private ?Game $game = null;
- /**
- * @var Collection<int, Slot>
- */
- #[ORM\OneToMany(targetEntity: Slot::class, mappedBy: 'party')]
- #[ORM\OrderBy(["startOn" => "ASC"])]
- private Collection $slots;
- #[ORM\ManyToOne(inversedBy: 'parties')]
- #[ORM\JoinColumn(nullable: false)]
- private ?Event $event = null;
- #[ORM\Column(nullable: true)]
- private ?\DateTime $startOn = null;
- #[ORM\Column(nullable: true)]
- private ?\DateTime $endOn = null;
- #[ORM\Column(nullable: true)]
- private ?bool $gamemasterIsAuthor = null;
- #[ORM\Column(nullable: true)]
- private ?int $minParticipants = null;
- #[ORM\Column(nullable: true)]
- private ?int $maxParticipants = null;
- #[ORM\Column(type: Types::TEXT, nullable: true)]
- private ?string $description = null;
- #[ORM\ManyToOne(inversedBy: 'submittedParties')]
- private ?User $submitter = null;
- #[ORM\Column(nullable: true)]
- private ?\DateTime $submittedDate = null;
- #[ORM\Column(nullable: true)]
- private ?bool $validated = null;
- /**
- * @var Collection<int, Participation>
- */
- #[ORM\OneToMany(targetEntity: Participation::class, mappedBy: 'party', orphanRemoval: true)]
- private Collection $participations;
- public function __construct()
- {
- $this->slots = new ArrayCollection();
- $this->participations = new ArrayCollection();
- }
- public function getId(): ?Uuid
- {
- return $this->id;
- }
- public function setId(Uuid $id): static
- {
- $this->id = $id;
- return $this;
- }
- public function getGamemaster(): ?Gamemaster
- {
- return $this->gamemaster;
- }
- public function setGamemaster(?Gamemaster $gamemaster): static
- {
- $this->gamemaster = $gamemaster;
- return $this;
- }
- public function getGame(): ?Game
- {
- return $this->game;
- }
- public function setGame(?Game $game): static
- {
- $this->game = $game;
- return $this;
- }
- /**
- * @return Collection<int, Slot>
- */
- public function getSlots(): Collection
- {
- return $this->slots;
- }
- public function addSlot(Slot $slot): static
- {
- if (!$this->slots->contains($slot)) {
- $this->slots->add($slot);
- $slot->setParty($this);
- }
- return $this;
- }
- public function removeSlot(Slot $slot): static
- {
- if ($this->slots->removeElement($slot)) {
- // set the owning side to null (unless already changed)
- if ($slot->getParty() === $this) {
- $slot->setParty(null);
- }
- }
- return $this;
- }
- public function purgeSlots(): static
- {
- foreach ($this->getSlots() as $slot) {
- $this->removeSlot($slot);
- }
- return $this;
- }
- public function getEvent(): ?Event
- {
- return $this->event;
- }
- public function setEvent(?Event $event): static
- {
- $this->event = $event;
- return $this;
- }
- public function getStartOn(): ?\DateTime
- {
- return $this->startOn;
- }
- public function setStartOn(?\DateTime $startOn): static
- {
- $this->startOn = $startOn;
- return $this;
- }
- public function getEndOn(): ?\DateTime
- {
- return $this->endOn;
- }
- public function setEndOn(?\DateTime $endOn): static
- {
- $this->endOn = $endOn;
- return $this;
- }
- public function isGamemasterIsAuthor(): ?bool
- {
- return $this->gamemasterIsAuthor;
- }
- public function setGamemasterIsAuthor(?bool $gamemasterIsAuthor): static
- {
- $this->gamemasterIsAuthor = $gamemasterIsAuthor;
- return $this;
- }
- public function getMinParticipants(): ?int
- {
- return $this->minParticipants;
- }
- public function setMinParticipants(?int $minParticipants): static
- {
- $this->minParticipants = $minParticipants;
- return $this;
- }
- public function getMaxParticipants(): ?int
- {
- return $this->maxParticipants;
- }
- public function setMaxParticipants(?int $maxParticipants): static
- {
- $this->maxParticipants = $maxParticipants;
- return $this;
- }
- public function getSeatsOccuped(): ?int
- {
- $seatsOccuped = count($this->getParticipations());
- return $seatsOccuped;
- }
- public function getSeatsLeft(): ?int
- {
- $seatsLeft = $this->maxParticipants - count($this->getParticipations());
- return $seatsLeft;
- }
- public function getDescription(): ?string
- {
- return $this->description;
- }
- public function setDescription(?string $description): static
- {
- $this->description = $description;
- return $this;
- }
- public function getSubmitter(): ?User
- {
- return $this->submitter;
- }
- public function setSubmitter(?User $submitter): static
- {
- $this->submitter = $submitter;
- return $this;
- }
- public function getSubmittedDate(): ?\DateTime
- {
- return $this->submittedDate;
- }
- public function setSubmittedDate(?\DateTime $submittedDate): static
- {
- $this->submittedDate = $submittedDate;
- return $this;
- }
- public function isValidated(): ?bool
- {
- return $this->validated;
- }
- public function setValidated(?bool $validated): static
- {
- $this->validated = $validated;
- return $this;
- }
- /**
- * @return Collection<int, Participation>
- */
- public function getParticipations(): Collection
- {
- return $this->participations;
- }
- public function addParticipation(Participation $participation): static
- {
- if (!$this->participations->contains($participation)) {
- $this->participations->add($participation);
- $participation->setParty($this);
- }
- return $this;
- }
- public function removeParticipation(Participation $participation): static
- {
- if ($this->participations->removeElement($participation)) {
- // set the owning side to null (unless already changed)
- if ($participation->getParty() === $this) {
- $participation->setParty(null);
- }
- }
- return $this;
- }
- }
|