src/Entity/Parrainage.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ParrainageRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=ParrainageRepository::class)
  9.  */
  10. class Parrainage
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="datetime_immutable")
  20.      */
  21.     private $createdAt;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $mail;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      */
  29.     private $token;
  30.     /**
  31.      * @ORM\Column(type="boolean", nullable=true)
  32.      */
  33.     private $isVisible;
  34.     /**
  35.      * @ORM\Column(type="datetime")
  36.      */
  37.     private $dateLimit;
  38.     /**
  39.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="parrainages")
  40.      * @ORM\JoinColumn(nullable=false)
  41.      */
  42.     private $user;
  43.     /**
  44.      * @ORM\OneToMany(targetEntity=IctusCommande::class, mappedBy="parrainage")
  45.      */
  46.     private $ictusCommandes;
  47.     /**
  48.      * @ORM\Column(type="string", length=255, nullable=true)
  49.      */
  50.     private $firstname;
  51.     /**
  52.      * @ORM\Column(type="string", length=255, nullable=true)
  53.      */
  54.     private $lastname;
  55.     /**
  56.      * @ORM\Column(type="datetime", nullable=true)
  57.      */
  58.     private $isClick;
  59.     public function __construct()
  60.     {
  61.         $date = new \DateTimeImmutable();
  62.         $date->modify('+2 hours');
  63.         $this->createdAt $date;
  64.         $this->ictusCommandes = new ArrayCollection();
  65.     }
  66.     public function getId(): ?int
  67.     {
  68.         return $this->id;
  69.     }
  70.     public function getCreatedAt(): ?\DateTimeImmutable
  71.     {
  72.         return $this->createdAt;
  73.     }
  74.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  75.     {
  76.         $this->createdAt $createdAt;
  77.         return $this;
  78.     }
  79.     public function getMail(): ?string
  80.     {
  81.         return $this->mail;
  82.     }
  83.     public function setMail(string $mail): self
  84.     {
  85.         $this->mail $mail;
  86.         return $this;
  87.     }
  88.     public function getToken(): ?string
  89.     {
  90.         return $this->token;
  91.     }
  92.     public function setToken(string $token): self
  93.     {
  94.         $this->token $token;
  95.         return $this;
  96.     }
  97.     public function isIsVisible(): ?bool
  98.     {
  99.         return $this->isVisible;
  100.     }
  101.     public function setIsVisible(?bool $isVisible): self
  102.     {
  103.         $this->isVisible $isVisible;
  104.         return $this;
  105.     }
  106.     public function getDateLimit(): ?\DateTimeInterface
  107.     {
  108.         return $this->dateLimit;
  109.     }
  110.     public function setDateLimit(\DateTimeInterface $dateLimit): self
  111.     {
  112.         $this->dateLimit $dateLimit;
  113.         return $this;
  114.     }
  115.     public function getUser(): ?User
  116.     {
  117.         return $this->user;
  118.     }
  119.     public function setUser(?User $user): self
  120.     {
  121.         $this->user $user;
  122.         return $this;
  123.     }
  124.     /**
  125.      * @return Collection<int, IctusCommande>
  126.      */
  127.     public function getIctusCommandes(): Collection
  128.     {
  129.         return $this->ictusCommandes;
  130.     }
  131.     public function addIctusCommande(IctusCommande $ictusCommande): self
  132.     {
  133.         if (!$this->ictusCommandes->contains($ictusCommande)) {
  134.             $this->ictusCommandes[] = $ictusCommande;
  135.             $ictusCommande->setParrainage($this);
  136.         }
  137.         return $this;
  138.     }
  139.     public function removeIctusCommande(IctusCommande $ictusCommande): self
  140.     {
  141.         if ($this->ictusCommandes->removeElement($ictusCommande)) {
  142.             // set the owning side to null (unless already changed)
  143.             if ($ictusCommande->getParrainage() === $this) {
  144.                 $ictusCommande->setParrainage(null);
  145.             }
  146.         }
  147.         return $this;
  148.     }
  149.     public function getFirstname(): ?string
  150.     {
  151.         return $this->firstname;
  152.     }
  153.     public function setFirstname(?string $firstname): self
  154.     {
  155.         $this->firstname $firstname;
  156.         return $this;
  157.     }
  158.     public function getLastname(): ?string
  159.     {
  160.         return $this->lastname;
  161.     }
  162.     public function setLastname(?string $lastname): self
  163.     {
  164.         $this->lastname $lastname;
  165.         return $this;
  166.     }
  167.     public function getTotalPaiement(): ?float
  168.     {
  169.         $total 0;
  170.         foreach ($this->getIctusCommandes() as $commande) {
  171.             $total += $commande->getTotalCommande();
  172.         }
  173.         return $total;
  174.     }
  175.     public function getIsClick(): ?\DateTimeInterface
  176.     {
  177.         return $this->isClick;
  178.     }
  179.     public function setIsClick(?\DateTimeInterface $isClick): self
  180.     {
  181.         $this->isClick $isClick;
  182.         return $this;
  183.     }
  184. }