src/Entity/Person.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Package;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Exception;
  7. use Serializable;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. #[ORM\Table(name'person')]
  13. #[ORM\Entity(repositoryClass'App\Repository\PersonRepository')]
  14. class Person extends User
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue(strategy'AUTO')]
  18.     #[ORM\Column(type'integer'uniquetrue)]
  19.     #[Groups(['login'])]
  20.     protected $id;
  21.     #[ORM\Column(name'email'type'string'length255nullabletrue)]
  22.     #[Groups(['login'])]
  23.     protected $email;
  24.     #[ORM\Column(name'street'type'string'length255nullabletrue)]
  25.     protected $street;
  26.     #[ORM\Column(name'streetnumber'type'smallint'nullabletrue)]
  27.     protected $streetnumber;
  28.     #[ORM\Column(name'postcode'type'smallint'nullabletrue)]
  29.     protected $postcode;
  30.     #[ORM\Column(name'city'type'string',length255nullabletrue)]
  31.     protected $city;
  32.     #[ORM\Column(name'region'type'string',length255nullabletrue)]
  33.     protected $region;
  34.     #[ORM\Column(name'country'type'string',length255nullabletrue)]
  35.     protected $country;
  36.     #[ORM\Column(name'phone'type'string',length255nullabletrue)]
  37.     protected $phone;
  38.     #[ORM\Column(type'date'nullabletrue)]
  39.     private $dateBirth;
  40.     #[ORM\OneToMany(targetEntityCommunauty::class, mappedBy'createur'orphanRemovaltrue)]
  41.     private $covoiturages;
  42.     #[ORM\OneToMany(targetEntityParticipation::class, mappedBy'participant')]
  43.     private $participations;
  44.     #[ORM\OneToMany(targetEntityCovInvitation::class, mappedBy'user')]
  45.     private $covInvitations;
  46.     #[ORM\OneToMany(targetEntityCovInvitation::class, mappedBy'friend')]
  47.     private $covOthersInvitations;
  48.     #[ORM\OneToMany(targetEntityCovFavorite::class, mappedBy'user')]
  49.     private $covFavorites;
  50.     #[ORM\OneToMany(targetEntityActivity::class, mappedBy'user')]
  51.     private $activities;
  52.     #[ORM\OneToMany(targetEntityCart::class, mappedBy'creator')]
  53.     private $carts;
  54.     #[ORM\ManyToMany(targetEntity'App\Entity\Package'inversedBy'persons'cascade: ['persist'], fetch'EAGER')]
  55.     #[ORM\JoinColumn(name'package_id'referencedColumnName'id'nullabletrue)]
  56.     private $packages;
  57.     public function __construct()
  58.     {
  59.       $this->covoiturages = new ArrayCollection();
  60.       $this->participations = new ArrayCollection();
  61.       $this->covInvitations = new ArrayCollection();
  62.       $this->covOthersInvitations = new ArrayCollection();
  63.       $this->covFavorites = new ArrayCollection();
  64.       $this->activities = new ArrayCollection();
  65.       $this->carts = new ArrayCollection();
  66.       $this->packages = new ArrayCollection();
  67.     }
  68.     /***********Getters&Setters***********/
  69.     /**
  70.      * @return string
  71.      */
  72.     public function getCity()
  73.     {
  74.         return $this->city;
  75.     }
  76.     /**
  77.      * @param string $city
  78.      */
  79.     public function setCity($city)
  80.     {
  81.         $this->city $city;
  82.     }
  83.     /**
  84.      * @return int
  85.      */
  86.     public function getCountry()
  87.     {
  88.         return $this->country;
  89.     }
  90.     /**
  91.      * @param int $country
  92.      */
  93.     public function setCountry($country)
  94.     {
  95.         $this->country $country;
  96.     }
  97.     /**
  98.      * @return int
  99.      */
  100.     public function getId()
  101.     {
  102.         return $this->id;
  103.     }
  104.     /**
  105.      * @param int $id
  106.      */
  107.     public function setId($id)
  108.     {
  109.         $this->id $id;
  110.     }
  111.     /**
  112.      * @return string
  113.      */
  114.     public function getPhone()
  115.     {
  116.         return $this->phone;
  117.     }
  118.     /**
  119.      * @param string $phone
  120.      */
  121.     public function setPhone($phone)
  122.     {
  123.         $this->phone $phone;
  124.     }
  125.     /**
  126.      * @return smallint
  127.      */
  128.     public function getPostcode()
  129.     {
  130.         return $this->postcode;
  131.     }
  132.     /**
  133.      * @param int $postcode
  134.      */
  135.     public function setPostcode($postcode)
  136.     {
  137.         $this->postcode $postcode;
  138.     }
  139.     /**
  140.      * @return string
  141.      */
  142.     public function getStreet()
  143.     {
  144.         return $this->street;
  145.     }
  146.     /**
  147.      * @param string $street
  148.      */
  149.     public function setStreet($street)
  150.     {
  151.         $this->street $street;
  152.     }
  153.     /**
  154.      * @return smallint
  155.      */
  156.     public function getStreetnumber()
  157.     {
  158.         return $this->streetnumber;
  159.     }
  160.     /**
  161.      * @param int $streetnumber
  162.      */
  163.     public function setStreetnumber($streetnumber)
  164.     {
  165.         $this->streetnumber $streetnumber;
  166.     }
  167.     /**
  168.      * @return string
  169.      */
  170.     public function getRegion()
  171.     {
  172.         return $this->region;
  173.     }
  174.     /**
  175.      * @return string
  176.      */
  177.     public function getEmail(): string
  178.     {
  179.         return $this->email;
  180.     }
  181.     /**
  182.      * @param string $email
  183.      */
  184.     public function setEmail($email): void
  185.     {
  186.         $this->email $email;
  187.     }
  188.     /**
  189.      * @return string
  190.      */
  191.     public function getToken(): ?string
  192.     {
  193.         return $this->token;
  194.     }
  195.     /**
  196.      * @return bool
  197.      */
  198.     public function isEmailValidated(): ?bool
  199.     {
  200.         return $this->emailValidated;
  201.     }
  202.     /**
  203.      * @return bool
  204.      */
  205.     public function isActived(): ?bool
  206.     {
  207.         return $this->actived;
  208.     }
  209.     /**
  210.      * @return \DateTime
  211.      */
  212.     public function getInscriptiondate(): ?\DateTime
  213.     {
  214.         return $this->inscriptiondate;
  215.     }
  216.     /**
  217.      * @param string $region
  218.      */
  219.     public function setRegion($region)
  220.     {
  221.         $this->region $region;
  222.     }
  223.     public function getDateBirth(): ?\DateTimeInterface
  224.     {
  225.         return $this->dateBirth;
  226.     }
  227.     public function setDateBirth(?\DateTimeInterface $dateBirth): self
  228.     {
  229.         $this->dateBirth $dateBirth;
  230.         return $this;
  231.     }
  232.     /**
  233.      * @return Collection|Communauty[]
  234.      */
  235.     public function getCovoiturages(): Collection
  236.     {
  237.         return $this->covoiturages;
  238.     }
  239.     public function addCovoiturages(Communauty $covoiturage): self
  240.     {
  241.         if (!$this->covoiturages->contains($covoiturage)) {
  242.             $this->covoiturages[] = $covoiturage;
  243.             $covoiturage->setCreateur($this);
  244.         }
  245.         return $this;
  246.     }
  247.     public function removeCovoiturages(Communauty $covoiturage): self
  248.     {
  249.         if ($this->covoiturages->removeElement($covoiturage)) {
  250.             // set the owning side to null (unless already changed)
  251.             if ($covoiturage->getCreateur() === $this) {
  252.                 $covoiturage->setCreateur(null);
  253.             }
  254.         }
  255.         return $this;
  256.     }
  257.     /**
  258.      * @return Collection|Participation[]
  259.      */
  260.     public function getParticipations(): Collection
  261.     {
  262.         return $this->participations;
  263.     }
  264.     public function addParticipation(Participation $participation): self
  265.     {
  266.         if (!$this->participations->contains($participation)) {
  267.             $this->participations[] = $participation;
  268.             $participation->setParticipant($this);
  269.         }
  270.         return $this;
  271.     }
  272.     public function removeParticipation(Participation $participation): self
  273.     {
  274.         if ($this->participations->removeElement($participation)) {
  275.             // set the owning side to null (unless already changed)
  276.             if ($participation->getParticipant() === $this) {
  277.                 $participation->setParticipant(null);
  278.             }
  279.         }
  280.         return $this;
  281.     }
  282.     /**
  283.      * @return Collection|CovInvitation[]
  284.      */
  285.     public function getCovInvitations(): Collection
  286.     {
  287.         return $this->covInvitations;
  288.     }
  289.     public function addCovInvitation(CovInvitation $covInvitation): self
  290.     {
  291.         if (!$this->covInvitations->contains($covInvitation)) {
  292.             $this->covInvitations[] = $covInvitation;
  293.             $covInvitation->setUser($this);
  294.         }
  295.         return $this;
  296.     }
  297.     public function removeCovInvitation(CovInvitation $covInvitation): self
  298.     {
  299.         if ($this->covInvitations->removeElement($covInvitation)) {
  300.             // set the owning side to null (unless already changed)
  301.             if ($covInvitation->getUser() === $this) {
  302.                 $covInvitation->setUser(null);
  303.             }
  304.         }
  305.         return $this;
  306.     }
  307.     /**
  308.      * @return Collection|CovInvitation[]
  309.      */
  310.     public function getCovOthersInvitations(): Collection
  311.     {
  312.         return $this->covOthersInvitations;
  313.     }
  314.     public function addCovOthersInvitation(CovInvitation $covOthersInvitation): self
  315.     {
  316.         if (!$this->covOthersInvitations->contains($covOthersInvitation)) {
  317.             $this->covOthersInvitations[] = $covOthersInvitation;
  318.             $covOthersInvitation->setFriend($this);
  319.         }
  320.         return $this;
  321.     }
  322.     public function removeCovOthersInvitation(CovInvitation $covOthersInvitation): self
  323.     {
  324.         if ($this->covOthersInvitations->removeElement($covOthersInvitation)) {
  325.             // set the owning side to null (unless already changed)
  326.             if ($covOthersInvitation->getFriend() === $this) {
  327.                 $covOthersInvitation->setFriend(null);
  328.             }
  329.         }
  330.         return $this;
  331.     }
  332.     /**
  333.      * @return Collection|CovFavorite[]
  334.      */
  335.     public function getCovFavorites(): Collection
  336.     {
  337.         return $this->covFavorites;
  338.     }
  339.     public function addCovFavorite(CovFavorite $covFavorite): self
  340.     {
  341.         if (!$this->covFavorites->contains($covFavorite)) {
  342.             $this->covFavorites[] = $covFavorite;
  343.             $covFavorite->setUser($this);
  344.         }
  345.         return $this;
  346.     }
  347.     public function removeCovFavorite(CovFavorite $covFavorite): self
  348.     {
  349.         if ($this->covFavorites->removeElement($covFavorite)) {
  350.             // set the owning side to null (unless already changed)
  351.             if ($covFavorite->getUser() === $this) {
  352.                 $covFavorite->setUser(null);
  353.             }
  354.         }
  355.         return $this;
  356.     }
  357.     /**
  358.      * @return Collection|Activity[]
  359.      */
  360.     public function getActivities(): Collection
  361.     {
  362.         return $this->activities;
  363.     }
  364.     public function addActivity(Activity $activity): self
  365.     {
  366.         if (!$this->activities->contains($activity)) {
  367.             $this->activities[] = $activity;
  368.             $activity->setUser($this);
  369.         }
  370.         return $this;
  371.     }
  372.     public function removeActivity(Activity $activity): self
  373.     {
  374.         if ($this->activities->removeElement($activity)) {
  375.             // set the owning side to null (unless already changed)
  376.             if ($activity->getUser() === $this) {
  377.                 $activity->setUser(null);
  378.             }
  379.         }
  380.         return $this;
  381.     }
  382.     /**
  383.      * @return Collection|Cart[]
  384.      */
  385.     public function getCarts(): ?Collection
  386.     {
  387.         return $this->carts;
  388.     }
  389.     public function addCart(Cart $cart): self
  390.     {
  391.         if (!$this->carts->contains($cart)) {
  392.             $this->carts[] = $cart;
  393.             $cart->setCreator($this);
  394.         }
  395.         return $this;
  396.     }
  397.     public function removeCart(Cart $cart): self
  398.     {
  399.         if ($this->carts->removeElement($cart)) {
  400.             // set the owning side to null (unless already changed)
  401.             if ($cart->getCreator() === $this) {
  402.                 $cart->setCreator(null);
  403.             }
  404.         }
  405.         return $this;
  406.     }
  407.     public function getPackages()
  408.     {
  409.         return $this->packages;
  410.     }
  411. /*    public function setPackage(?Package $package): self
  412.     {
  413.         $this->package = $package;
  414.         return $this;
  415.     }*/
  416.     public function addPackage(Package $package): self
  417.     {
  418.         if (!$this->packages->contains($package)) {
  419.             $this->packages[] = $package;
  420.         }
  421.         return $this;
  422.     }
  423.     public function removePackage(Package $package): self
  424.     {
  425.         $this->packages->removeElement($package);
  426.         return $this;
  427.     }
  428. }