src/Entity/Sponsorship.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Enum\SponsorshipStateEnum;
  4. use App\Repository\SponsorshipRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. /**
  8.  * @ORM\Entity(repositoryClass=SponsorshipRepository::class)
  9.  * @ORM\EntityListeners({"App\Listener\SponsorshipListener"})
  10.  */
  11. class Sponsorship
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="datetime")
  21.      * @Gedmo\Timestampable(on="create")
  22.      */
  23.     private $created;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $email;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      */
  31.     private $recipientFirstname;
  32.     /**
  33.      * @ORM\Column(type="string", length=255)
  34.      */
  35.     private $recipientLastname;
  36.     /**
  37.      * @ORM\Column(type="string", length=255)
  38.      */
  39.     private $senderName;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity=User::class)
  42.      * @ORM\JoinColumn(nullable=false)
  43.      */
  44.     private $senderUser;
  45.     /**
  46.      * @ORM\OneToOne(targetEntity=User::class)
  47.      */
  48.     private $recipientUser;
  49.     /**
  50.      * @ORM\Column(type="string", length=5)
  51.      */
  52.     private $state=SponsorshipStateEnum::SENT;
  53.     /**
  54.      * @ORM\Column(type="string", length=100, nullable=true, unique=true)
  55.      */
  56.     private $token;
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getEmail(): ?string
  62.     {
  63.         return $this->email;
  64.     }
  65.     public function setEmail(string $email): self
  66.     {
  67.         $this->email $email;
  68.         return $this;
  69.     }
  70.     public function getRecipientFirstname(): ?string
  71.     {
  72.         return $this->recipientFirstname;
  73.     }
  74.     public function setRecipientFirstname(string $recipientFirstname): self
  75.     {
  76.         $this->recipientFirstname $recipientFirstname;
  77.         return $this;
  78.     }
  79.     public function getRecipientLastname(): ?string
  80.     {
  81.         return $this->recipientLastname;
  82.     }
  83.     public function setRecipientLastname(string $recipientLastname): self
  84.     {
  85.         $this->recipientLastname $recipientLastname;
  86.         return $this;
  87.     }
  88.     public function getSenderName(): ?string
  89.     {
  90.         return $this->senderName;
  91.     }
  92.     public function setSenderName(string $senderName): self
  93.     {
  94.         $this->senderName $senderName;
  95.         return $this;
  96.     }
  97.     public function getSenderUser(): ?User
  98.     {
  99.         return $this->senderUser;
  100.     }
  101.     public function setSenderUser(?User $senderUser): self
  102.     {
  103.         $this->senderUser $senderUser;
  104.         return $this;
  105.     }
  106.     public function getRecipientUser(): ?User
  107.     {
  108.         return $this->recipientUser;
  109.     }
  110.     public function setRecipientUser(?User $recipientUser): self
  111.     {
  112.         $this->recipientUser $recipientUser;
  113.         return $this;
  114.     }
  115.     public function getState(): ?string
  116.     {
  117.         return $this->state;
  118.     }
  119.     public function setState(string $state): self
  120.     {
  121.         $this->state $state;
  122.         return $this;
  123.     }
  124.     public function getToken(): ?string
  125.     {
  126.         return $this->token;
  127.     }
  128.     public function setToken(?string $token): self
  129.     {
  130.         $this->token $token;
  131.         return $this;
  132.     }
  133.     public function generateToken(){
  134.         return $this->setToken(md5($this->getEmail().time().'sponsor'));
  135.     }
  136.     /**
  137.      * @return mixed
  138.      */
  139.     public function getCreated()
  140.     {
  141.         return $this->created;
  142.     }
  143.     /**
  144.      * @param mixed $created
  145.      */
  146.     public function setCreated($created): void
  147.     {
  148.         $this->created $created;
  149.     }
  150. }