src/Entity/Device/Device.php line 28

  1. <?php
  2. /*
  3.  * This file is part of the Pellipop project.
  4.  *
  5.  * (c) Mobizel
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace App\Entity\Device;
  12. use ApiPlatform\Metadata\ApiProperty;
  13. use App\Entity\Customer\Customer;
  14. use App\Entity\IdentifiableTrait;
  15. use App\Repository\Device\DeviceRepository;
  16. use Doctrine\ORM\Mapping as ORM;
  17. use Sylius\Component\Resource\Model\ResourceInterface;
  18. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  19. use Symfony\Component\Validator\Constraints as Assert;
  20. #[ORM\Entity(repositoryClassDeviceRepository::class)]
  21. #[ORM\Table(name'app_device')]
  22. #[UniqueEntity(fields: ['token'])]
  23. class Device implements ResourceInterface
  24. {
  25.     use IdentifiableTrait;
  26.     #[ORM\Id]
  27.     #[ORM\GeneratedValue]
  28.     #[ORM\Column(type'integer')]
  29.     #[ApiProperty(identifierfalse)]
  30.     protected ?int $id null;
  31.     #[ORM\Column(type'string'uniquetrue)]
  32.     #[Assert\NotBlank]
  33.     #[ApiProperty(identifiertrue)]
  34.     private string $token;
  35.     #[ORM\ManyToOne(targetEntityCustomer::class, inversedBy'devices')]
  36.     #[ORM\JoinColumn(nullabletrue)]
  37.     private Customer $customer;
  38.     public function getToken(): string
  39.     {
  40.         return $this->token;
  41.     }
  42.     public function setToken(string $token): void
  43.     {
  44.         $this->token $token;
  45.     }
  46.     public function getCustomer(): ?Customer
  47.     {
  48.         return $this->customer;
  49.     }
  50.     public function setCustomer(?Customer $customer): void
  51.     {
  52.         $this->customer $customer;
  53.     }
  54. }