1
0
mirror of https://framagit.org/tykayn/date-poll-api synced 2023-08-25 08:23:11 +02:00
date-poll-api/src/Entity/Owner.php

95 lines
1.7 KiB
PHP
Raw Normal View History

2019-10-25 14:59:20 +02:00
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
2019-11-06 12:27:46 +01:00
use JMS\Serializer\Annotation as Serializer;
2019-10-25 14:59:20 +02:00
/**
* @ORM\Entity(repositoryClass="App\Repository\OwnerRepository")
*/
2019-11-06 12:27:46 +01:00
class Owner {
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Type("string")
*/
private $email;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Type("string")
*/
private $pseudo;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Poll", mappedBy="owner",cascade={"persist"})
* @Serializer\Type("App\Entity\Poll")
*/
private $polls;
public function __construct() {
$this->polls = new ArrayCollection();
}
public function getId(): ?int {
return $this->id;
}
public function getEmail(): ?string {
return $this->email;
}
public function setEmail( string $email ): self {
$this->email = $email;
return $this;
}
public function getPseudo(): ?string {
return $this->pseudo;
}
public function setPseudo( string $pseudo ): self {
$this->pseudo = $pseudo;
return $this;
}
/**
* @return Collection|Poll[]
*/
public function getPolls(): Collection {
return $this->polls;
}
public function addPoll( Poll $poll ): self {
if ( ! $this->polls->contains( $poll ) ) {
$this->polls[] = $poll;
$poll->setOwner( $this );
}
return $this;
}
public function removePoll( Poll $poll ): self {
if ( $this->polls->contains( $poll ) ) {
$this->polls->removeElement( $poll );
// set the owning side to null (unless already changed)
if ( $poll->getOwner() === $this ) {
$poll->setOwner( null );
}
}
return $this;
}
2019-10-25 14:59:20 +02:00
}