src/Entity/Accounts/UserTokens.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Accounts;
  3. use Doctrine\DBAL\Types\Types;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * Usertokens
  7.  * @ORM\Entity(repositoryClass="App\Repository\Accounts\UserTokensRepository")
  8.  * @ORM\Table(name="otp_accounts.userTokens", indexes={
  9.  *     @ORM\Index(name="user_id", columns={"user_id"}),
  10.  *     @ORM\Index(name="token", columns={"token"})
  11.  * })
  12.  */
  13. class UserTokens
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue(strategy="IDENTITY")
  18.      * @ORM\Column(type="integer", options={"unsigned"=true})
  19.      */
  20.     private int $id;
  21.     /**
  22.      * @ORM\Column(type="integer", options={"unsigned"=true})
  23.      */
  24.     private int $user_id;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity="App\Entity\Accounts\Users", inversedBy="tokens")
  27.      * @ORM\JoinColumn(name="user_id", referencedColumnName="rec_id", nullable=false, onDelete="CASCADE")
  28.      */
  29.     private $user;
  30.     public function getUser(): ?Users
  31.     {
  32.         return $this->user;
  33.     }
  34.     public function setUser(Users $user): static
  35.     {
  36.         $this->user $user;
  37.         return $this;
  38.     }
  39.     /**
  40.      * @ORM\Column(type="string", length=40, nullable=true)
  41.      */
  42.     private string $user_agent;
  43.     /**
  44.      * @ORM\Column(type="integer", options={"unsigned"=true}, nullable=true)
  45.      */
  46.     private int $ip;
  47.     /**
  48.      * @ORM\Column(type="string", length=255)
  49.      */
  50.     private string $token;
  51.     /**
  52.      * @ORM\Column(type="string", length=100, nullable=true)
  53.      */
  54.     private string $type='';
  55.     /**
  56.      * @ORM\Column(type="integer", options={"unsigned"=true})
  57.      */
  58.     private int $created;
  59.     /**
  60.      * @ORM\Column(type="integer", nullable=true, options={"unsigned"=true})
  61.      */
  62.     private int $expires;
  63.     // Геттери та сеттери:
  64.     public function getId(): int
  65.     {
  66.         return $this->id;
  67.     }
  68.     public function getUserId(): int
  69.     {
  70.         return $this->user_id;
  71.     }
  72.     public function setUserId(int $user_id): static
  73.     {
  74.         $this->user_id $user_id;
  75.         return $this;
  76.     }
  77.     public function getUserAgent(): string
  78.     {
  79.         return $this->user_agent;
  80.     }
  81.     public function setUserAgent(string $user_agent): static
  82.     {
  83.         $this->user_agent $user_agent;
  84.         return $this;
  85.     }
  86.     public function getIp(): string
  87.     {
  88.         if (is_numeric($this->ip)) return long2ip($this->ip);
  89.         return $this->ip;
  90.     }
  91.     public function setIp(string $ip): static
  92.     {
  93.         if (is_numeric($ip)) $this->ip $ip;
  94.         else $this->ip ip2long($ip);
  95.         return $this;
  96.     }
  97.     public function getToken(): string
  98.     {
  99.         return $this->token;
  100.     }
  101.     public function setToken(string $token): static
  102.     {
  103.         $this->token $token;
  104.         return $this;
  105.     }
  106.     public function getType(): string
  107.     {
  108.         return $this->type;
  109.     }
  110.     public function setType(string $type): static
  111.     {
  112.         $this->type $type;
  113.         return $this;
  114.     }
  115.     public function getCreated(): int
  116.     {
  117.         return $this->created;
  118.     }
  119.     public function setCreated(int $created): static
  120.     {
  121.         $this->created $created;
  122.         return $this;
  123.     }
  124.     public function setDate(\DateTimeInterface $date): static
  125.     {
  126.         $this->created $date->getTimestamp();
  127.         return $this;
  128.     }
  129.     public function getExpires(): int
  130.     {
  131.         return $this->expires;
  132.     }
  133.     public function setExpires(int $expires): static
  134.     {
  135.         $this->expires $expires;
  136.         return $this;
  137.     }
  138. }