|
- <?php
-
- namespace App\Entity\User;
-
- use App\Entity\CollectifData\CollectifData;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\SovBundle\Model\User\UserModel as SovUserModel;
- use Lc\SovBundle\Model\User\UserInterface;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
-
- /**
- * @ORM\Entity(repositoryClass="Lc\SovBundle\Repository\User\UserRepository")
- * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
- */
- class User extends SovUserModel implements UserInterface
- {
- /**
- * @ORM\Id
- * @ORM\GeneratedValue
- * @ORM\Column(type="integer")
- */
- private $id;
-
- /**
- * @ORM\OneToMany(targetEntity=CollectifData::class, mappedBy="user")
- */
- private $collectifData;
-
- public function __construct()
- {
- $this->collectifData = new ArrayCollection();
- }
-
- public function __toString()
- {
- return $this->firstname . " " . $this->lastname;
- }
-
- public function getId(): ?int
- {
- return $this->id;
- }
-
- /**
- * @return Collection|CollectifData[]
- */
- public function getCollectifData(): Collection
- {
- return $this->collectifData;
- }
-
- public function addCollectifData(CollectifData $collectifData): self
- {
- if (!$this->collectifData->contains($collectifData)) {
- $this->collectifData[] = $collectifData;
- $collectifData->setUser($this);
- }
-
- return $this;
- }
-
- public function removeCollectifData(CollectifData $collectifData): self
- {
- if ($this->collectifData->removeElement($collectifData)) {
- // set the owning side to null (unless already changed)
- if ($collectifData->getUser() === $this) {
- $collectifData->setUser(null);
- }
- }
-
- return $this;
- }
-
- }
|