src/Entity/PasswordReset.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. /**
  7.  * @author <erwan> <erwan@kodiom.com>
  8.  *
  9.  * @ORM\Table()
  10.  * @ORM\Entity(repositoryClass="App\Repository\PasswordResetRepository")
  11.  * @ApiResource(
  12.  *     collectionOperations={
  13.  *        "get"={"method"="GET"},
  14.  *        "demand"={"route_name"="api_password_reset_demand"}
  15.  *     },
  16.  *     itemOperations={
  17.  *        "get"={"method"="GET"},
  18.  *        "reset"={"route_name"="api_password_reset_reset"}
  19.  *     }
  20.  * )
  21.  */
  22. class PasswordReset
  23. {
  24.     /**
  25.      * @var integer $id
  26.      *
  27.      * @ORM\Id
  28.      * @ORM\Column(type="integer")
  29.      * @ORM\GeneratedValue(strategy="AUTO")
  30.      */
  31.     private $id;
  32.     /**
  33.      * @var integer
  34.      *
  35.      * @ORM\Column(type="integer")
  36.      * @Assert\NotBlank()
  37.      */
  38.     private $code;
  39.     /**
  40.      * @var \DateTime
  41.      *
  42.      * @ORM\Column(type="datetime")
  43.      */
  44.     private $dateExpiration;
  45.     /**
  46.      * @var string
  47.      *
  48.      * @ORM\Column(type="string", length=255)
  49.      * @Assert\NotBlank()
  50.      */
  51.     private $email;
  52.     /**
  53.      * @var bool
  54.      *
  55.      * @ORM\Column(type="boolean")
  56.      */
  57.     private $actif;
  58.     /**
  59.      * Constructor of PasswordReset Entity
  60.      */
  61.     public function __construct()
  62.     {
  63.         $this->code mt_rand(100000999999);
  64.         $this->dateExpiration = new \DateTime();
  65.         $this->actif true;
  66.     }
  67.     public function __toString()
  68.     {
  69.         return ($this->getCode()) ? $this->getCode() : 'Unknown';
  70.     }
  71.     /**
  72.      * Get id
  73.      *
  74.      * @return integer
  75.      */
  76.     public function getId()
  77.     {
  78.         return $this->id;
  79.     }
  80.     /**
  81.      * Get code
  82.      *
  83.      * @return string
  84.      */
  85.     public function getCode()
  86.     {
  87.         return $this->code;
  88.     }
  89.     /**
  90.      * Set code
  91.      *
  92.      * @param string code
  93.      *
  94.      * @return PasswordReset
  95.      */
  96.     public function setCode($code)
  97.     {
  98.         $this->code $code;
  99.         return $this;
  100.     }
  101.     /**
  102.      * Set dateExpiration
  103.      *
  104.      * @param \DateTime $dateExpiration
  105.      * @return PasswordReset
  106.      */
  107.     public function setDateExpiration($dateExpiration)
  108.     {
  109.         $this->dateExpiration $dateExpiration;
  110.         return $this;
  111.     }
  112.     /**
  113.      * Get dateExpiration
  114.      *
  115.      * @return \DateTime
  116.      */
  117.     public function getDateExpiration()
  118.     {
  119.         return $this->dateExpiration;
  120.     }
  121.     /**
  122.      * Get email
  123.      *
  124.      * @return string
  125.      */
  126.     public function getEmail()
  127.     {
  128.         return $this->email;
  129.     }
  130.     /**
  131.      * Set email
  132.      *
  133.      * @param string email
  134.      *
  135.      * @return PasswordReset
  136.      */
  137.     public function setEmail($email)
  138.     {
  139.         $this->email $email;
  140.         return $this;
  141.     }
  142.     /**
  143.      * Get actif
  144.      *
  145.      * @return boolean
  146.      */
  147.     public function getActif()
  148.     {
  149.         return $this->actif;
  150.     }
  151.     /**
  152.      * Set actif
  153.      *
  154.      * @param bool $actif
  155.      *
  156.      * @return PasswordReset
  157.      */
  158.     public function setActif($actif)
  159.     {
  160.         $this->actif $actif;
  161.         return $this;
  162.     }
  163. }