src/Diplix/KMGBundle/Entity/DeviceToken.php line 10

Open in your IDE?
  1. <?php
  2. namespace Diplix\KMGBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Table(name="user_device_tokens", indexes={@ORM\Index(name="be_deleted",columns={"be_deleted"}),@ORM\Index(name="user_id",columns={"user_id"})})
  6.  * @ORM\Entity()
  7.  */
  8. class DeviceToken extends BasicEntity
  9. {
  10.     const FCM 'fcm';
  11.     /**
  12.      * @ORM\Column(type="integer",name="id")
  13.      * @ORM\Id()
  14.      * @ORM\GeneratedValue(strategy="AUTO")
  15.      */
  16.     protected $id;
  17.     /**
  18.      * @ORM\ManyToOne(targetEntity="Diplix\KMGBundle\Entity\User", inversedBy="deviceTokens")
  19.      * @ORM\JoinColumn(nullable=false, name="user_id")
  20.      */
  21.     protected $user;
  22.     /**
  23.      * @ORM\Column(type="string")
  24.      */
  25.     protected $platform;
  26.     /**
  27.      * @ORM\Column(type="string",name="token_type")
  28.      */
  29.     protected $type self::FCM;
  30.     /**
  31.      * @ORM\Column(type="string")
  32.      */
  33.     protected $token;
  34.     /**
  35.      * @ORM\Column(type="datetime")
  36.      */
  37.     protected $firstSeen;
  38.     /**
  39.      * @ORM\Column(type="datetime")
  40.      */
  41.     protected $lastSeen;
  42.     public static function create(User $user,$token,$platform): DeviceToken
  43.     {
  44.         $deviceToken = new DeviceToken();
  45.         $deviceToken->setUser($user);
  46.         $now = new \DateTime();
  47.         $deviceToken->setFirstSeen($now);
  48.         $deviceToken->setLastSeen($now);
  49.         $deviceToken->setToken($token);
  50.         $deviceToken->setPlatform($platform);
  51.         return $deviceToken;
  52.     }
  53.     /**
  54.      * @return mixed
  55.      */
  56.     public function getId()
  57.     {
  58.         return $this->id;
  59.     }
  60.     /**
  61.      * @return User
  62.      */
  63.     public function getUser()
  64.     {
  65.         return $this->user;
  66.     }
  67.     /**
  68.      * @param mixed $user
  69.      */
  70.     public function setUser($user): void
  71.     {
  72.         $this->user $user;
  73.     }
  74.     /**
  75.      * @return mixed
  76.      */
  77.     public function getPlatform()
  78.     {
  79.         return $this->platform;
  80.     }
  81.     /**
  82.      * @param mixed $platform
  83.      */
  84.     public function setPlatform($platform): void
  85.     {
  86.         $this->platform $platform;
  87.     }
  88.     /**
  89.      * @return string
  90.      */
  91.     public function getType(): string
  92.     {
  93.         return $this->type;
  94.     }
  95.     /**
  96.      * @param string $type
  97.      */
  98.     public function setType(string $type): void
  99.     {
  100.         $this->type $type;
  101.     }
  102.     /**
  103.      * @return mixed
  104.      */
  105.     public function getToken()
  106.     {
  107.         return $this->token;
  108.     }
  109.     /**
  110.      * @param mixed $token
  111.      */
  112.     public function setToken($token): void
  113.     {
  114.         $this->token $token;
  115.     }
  116.     /**
  117.      * @return mixed
  118.      */
  119.     public function getFirstSeen()
  120.     {
  121.         return $this->firstSeen;
  122.     }
  123.     /**
  124.      * @param mixed $firstSeen
  125.      */
  126.     public function setFirstSeen($firstSeen): void
  127.     {
  128.         $this->firstSeen $firstSeen;
  129.     }
  130.     /**
  131.      * @return mixed
  132.      */
  133.     public function getLastSeen()
  134.     {
  135.         return $this->lastSeen;
  136.     }
  137.     /**
  138.      * @param mixed $lastSeen
  139.      */
  140.     public function setLastSeen($lastSeen): void
  141.     {
  142.         $this->lastSeen $lastSeen;
  143.     }
  144. }