src/Entity/Identity/Passport.php line 40

  1. <?php
  2. namespace App\Entity\Identity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Delete;
  5. use ApiPlatform\Metadata\Get;
  6. use ApiPlatform\Metadata\GetCollection;
  7. use ApiPlatform\Metadata\Post;
  8. use ApiPlatform\Metadata\Put;
  9. use App\Doctrine\Type\Identity\PassportType;
  10. use App\Dto\Identity\PassportInput;
  11. use App\Dto\Identity\PassportUpdateInput;
  12. use App\Entity\Common;
  13. use App\Processor\Identity\PassportInputProcessor;
  14. use App\Processor\Identity\PassportUpdateProcessor;
  15. use App\Validator\IsValidEnum\IsValidEnum;
  16. use App\Validator\IsValidPassport\IsValidPassport;
  17. use Doctrine\DBAL\Types\Types;
  18. use Doctrine\ORM\Mapping as ORM;
  19. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. #[ORM\Table(name'user_passport')]
  22. #[ORM\Index(columns: ['owner_id'], name'user_passport_owner_id_idx')]
  23. #[ORM\Index(columns: ['created_by'], name'user_passport_created_by_idx')]
  24. #[ORM\Index(columns: ['updated_by'], name'user_passport_updated_by_idx')]
  25. #[ORM\UniqueConstraint(name'user_passport_value_key'columns: ['value'])]
  26. #[ORM\Entity]
  27. #[UniqueEntity('value')]
  28. #[ApiResource(
  29.     operations: [
  30.         new Get(),
  31.         new delete(),
  32.         new Put(inputPassportUpdateInput::class, processorPassportUpdateProcessor::class),
  33.         new Post(inputPassportInput::class, processorPassportInputProcessor::class),
  34.         new GetCollection(),
  35.     ]
  36. )]
  37. class Passport
  38. {
  39.     use Common\Blameable;
  40.     use Common\Trackable;
  41.     #[ORM\Id]
  42.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  43.     #[ORM\SequenceGenerator(sequenceName'user_passport_id_seq')]
  44.     #[ORM\Column(typeTypes::INTEGER)]
  45.     private ?int $id null;
  46.     #[Assert\NotNull]
  47.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'passports')]
  48.     #[ORM\JoinColumn(name'owner_id'nullablefalse)]
  49.     private ?User $owner null;
  50.     #[IsValidPassport]
  51.     #[Assert\NotBlank]
  52.     #[Assert\Type(typeTypes::STRING)]
  53.     #[ORM\Column(typeTypes::STRING)]
  54.     private ?string $value null;
  55.     #[Assert\NotNull]
  56.     #[IsValidEnum(enumPassportType::class)]
  57.     #[ORM\Column(typeTypes::STRINGenumTypePassportType::class)]
  58.     private ?PassportType $type null;
  59.     #[Assert\Type(typeTypes::BOOLEAN)]
  60.     #[ORM\Column(typeTypes::BOOLEANnullabletrue)]
  61.     private ?bool $verified false;
  62.     #[Assert\Type(typeTypes::BOOLEAN)]
  63.     #[ORM\Column(name'is_main'typeTypes::BOOLEANnullabletrue)]
  64.     private ?bool $main false;
  65.     #[ORM\ManyToOne(targetEntityUser::class)]
  66.     #[ORM\JoinColumn(name'created_by'nullabletrue)]
  67.     protected ?User $createdBy null;
  68.     public function getId(): ?int
  69.     {
  70.         return $this->id;
  71.     }
  72.     public function getOwner(): ?User
  73.     {
  74.         return $this->owner;
  75.     }
  76.     public function setOwner(?User $owner): self
  77.     {
  78.         $this->owner $owner;
  79.         return $this;
  80.     }
  81.     public function getValue(): ?string
  82.     {
  83.         return $this->value;
  84.     }
  85.     public function setValue(string $value): self
  86.     {
  87.         $this->value $value;
  88.         return $this;
  89.     }
  90.     public function getType(): ?PassportType
  91.     {
  92.         return $this->type;
  93.     }
  94.     public function setType(PassportType $type): self
  95.     {
  96.         $this->type $type;
  97.         return $this;
  98.     }
  99.     public function isVerified(): ?bool
  100.     {
  101.         return $this->verified;
  102.     }
  103.     public function setVerified(?bool $verified): self
  104.     {
  105.         $this->verified $verified;
  106.         return $this;
  107.     }
  108.     public function isMain(): ?bool
  109.     {
  110.         return $this->main;
  111.     }
  112.     public function setMain(?bool $main): self
  113.     {
  114.         $this->main $main;
  115.         return $this;
  116.     }
  117. }