date-poll-api/src/Entity/StackOfVotes.php

87 lines
1.7 KiB
PHP
Raw Normal View History

2019-11-11 10:44:19 +01:00
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
2019-11-12 11:26:19 +01:00
* contains the votes for one answer to a poll
2019-11-11 10:44:19 +01:00
* @ORM\Entity(repositoryClass="App\Repository\StackOfVotesRepository")
*/
2019-11-12 11:26:19 +01:00
class StackOfVotes {
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
2019-11-12 12:01:15 +01:00
* @ORM\OneToMany(targetEntity="App\Entity\poll", mappedBy="stacksOfVotes", cascade={"persist","remove"})
2019-11-12 11:26:19 +01:00
*/
private $votes;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Owner", inversedBy="stackOfVotes")
*/
private $owner;
public function __construct() {
$this->votes = new ArrayCollection();
}
public function getId(): ?int {
return $this->id;
}
/**
* @return Collection|poll[]
*/
public function getVotes(): Collection {
return $this->votes;
}
public function addVote( poll $vote ): self {
if ( ! $this->votes->contains( $vote ) ) {
$this->votes[] = $vote;
$vote->setStacksOfVotes( $this );
}
return $this;
}
public function removeVote( poll $vote ): self {
if ( $this->votes->contains( $vote ) ) {
$this->votes->removeElement( $vote );
// set the owning side to null (unless already changed)
if ( $vote->getStacksOfVotes() === $this ) {
$vote->setStacksOfVotes( null );
}
}
return $this;
}
public function getPseudo(): ?string {
return $this->pseudo;
}
public function setPseudo( ?string $pseudo ): self {
$this->pseudo = $pseudo;
return $this;
}
public function getOwner(): ?Owner {
return $this->owner;
}
public function setOwner( ?Owner $owner ): self {
$this->owner = $owner;
return $this;
}
2019-11-11 10:44:19 +01:00
}