src/Entity/Device.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DeviceRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=DeviceRepository::class)
  9.  */
  10. class Device
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="devices")
  20.      * @ORM\JoinColumn(nullable=false)
  21.      */
  22.     private $user;
  23.     /**
  24.      * @ORM\Column(type="text", nullable=true)
  25.      */
  26.     private $userAgent;
  27.     /**
  28.      * @ORM\Column(type="datetime")
  29.      */
  30.     private $createdAt;
  31.     /**
  32.      * @ORM\Column(type="datetime", nullable=true)
  33.      */
  34.     private $lastOnline;
  35.     /**
  36.      * @ORM\Column(type="string", length=255, nullable=true)
  37.      */
  38.     private $name;
  39.     /**
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      */
  42.     private $platform;
  43.     /**
  44.      * @ORM\OneToMany(targetEntity=AccessToken::class, mappedBy="device")
  45.      */
  46.     private $accessTokens;
  47.     /**
  48.      * @ORM\Column(type="string", length=255, unique=true)
  49.      */
  50.     private $deviceId;
  51.     public function __construct()
  52.     {
  53.         $this->accessTokens = new ArrayCollection();
  54.         $this->createdAt = new \DateTime();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getUser(): ?User
  61.     {
  62.         return $this->user;
  63.     }
  64.     public function setUser(?User $user): self
  65.     {
  66.         $this->user $user;
  67.         return $this;
  68.     }
  69.     public function getUserAgent(): ?string
  70.     {
  71.         return $this->userAgent;
  72.     }
  73.     public function setUserAgent(?string $userAgent): self
  74.     {
  75.         $this->userAgent $userAgent;
  76.         return $this;
  77.     }
  78.     public function getCreatedAt(): ?\DateTimeInterface
  79.     {
  80.         return $this->createdAt;
  81.     }
  82.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  83.     {
  84.         $this->createdAt $createdAt;
  85.         return $this;
  86.     }
  87.     public function getLastOnline(): ?\DateTimeInterface
  88.     {
  89.         return $this->lastOnline;
  90.     }
  91.     public function setLastOnline(?\DateTimeInterface $lastOnline): self
  92.     {
  93.         $this->lastOnline $lastOnline;
  94.         return $this;
  95.     }
  96.     public function getName(): ?string
  97.     {
  98.         return $this->name;
  99.     }
  100.     public function setName(?string $name): self
  101.     {
  102.         $this->name $name;
  103.         return $this;
  104.     }
  105.     public function getPlatform(): ?string
  106.     {
  107.         return $this->platform;
  108.     }
  109.     public function setPlatform(?string $platform): self
  110.     {
  111.         $this->platform $platform;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return Collection<int, AccessToken>
  116.      */
  117.     public function getAccessTokens(): Collection
  118.     {
  119.         return $this->accessTokens;
  120.     }
  121.     public function addAccessToken(AccessToken $accessToken): self
  122.     {
  123.         if (!$this->accessTokens->contains($accessToken)) {
  124.             $this->accessTokens[] = $accessToken;
  125.             $accessToken->setDevice($this);
  126.         }
  127.         return $this;
  128.     }
  129.     public function removeAccessToken(AccessToken $accessToken): self
  130.     {
  131.         if ($this->accessTokens->removeElement($accessToken)) {
  132.             // set the owning side to null (unless already changed)
  133.             if ($accessToken->getDevice() === $this) {
  134.                 $accessToken->setDevice(null);
  135.             }
  136.         }
  137.         return $this;
  138.     }
  139.     public function getDeviceId(): ?string
  140.     {
  141.         return $this->deviceId;
  142.     }
  143.     public function setDeviceId(string $deviceId): self
  144.     {
  145.         $this->deviceId $deviceId;
  146.         return $this;
  147.     }
  148. }