src/Entity/Identity/Passport.php line 40
<?php
namespace App\Entity\Identity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use App\Doctrine\Type\Identity\PassportType;
use App\Dto\Identity\PassportInput;
use App\Dto\Identity\PassportUpdateInput;
use App\Entity\Common;
use App\Processor\Identity\PassportInputProcessor;
use App\Processor\Identity\PassportUpdateProcessor;
use App\Validator\IsValidEnum\IsValidEnum;
use App\Validator\IsValidPassport\IsValidPassport;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Table(name: 'user_passport')]
#[ORM\Index(columns: ['owner_id'], name: 'user_passport_owner_id_idx')]
#[ORM\Index(columns: ['created_by'], name: 'user_passport_created_by_idx')]
#[ORM\Index(columns: ['updated_by'], name: 'user_passport_updated_by_idx')]
#[ORM\UniqueConstraint(name: 'user_passport_value_key', columns: ['value'])]
#[ORM\Entity]
#[UniqueEntity('value')]
#[ApiResource(
operations: [
new Get(),
new delete(),
new Put(input: PassportUpdateInput::class, processor: PassportUpdateProcessor::class),
new Post(input: PassportInput::class, processor: PassportInputProcessor::class),
new GetCollection(),
]
)]
class Passport
{
use Common\Blameable;
use Common\Trackable;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'user_passport_id_seq')]
#[ORM\Column(type: Types::INTEGER)]
private ?int $id = null;
#[Assert\NotNull]
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'passports')]
#[ORM\JoinColumn(name: 'owner_id', nullable: false)]
private ?User $owner = null;
#[IsValidPassport]
#[Assert\NotBlank]
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING)]
private ?string $value = null;
#[Assert\NotNull]
#[IsValidEnum(enum: PassportType::class)]
#[ORM\Column(type: Types::STRING, enumType: PassportType::class)]
private ?PassportType $type = null;
#[Assert\Type(type: Types::BOOLEAN)]
#[ORM\Column(type: Types::BOOLEAN, nullable: true)]
private ?bool $verified = false;
#[Assert\Type(type: Types::BOOLEAN)]
#[ORM\Column(name: 'is_main', type: Types::BOOLEAN, nullable: true)]
private ?bool $main = false;
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(name: 'created_by', nullable: true)]
protected ?User $createdBy = null;
public function getId(): ?int
{
return $this->id;
}
public function getOwner(): ?User
{
return $this->owner;
}
public function setOwner(?User $owner): self
{
$this->owner = $owner;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(string $value): self
{
$this->value = $value;
return $this;
}
public function getType(): ?PassportType
{
return $this->type;
}
public function setType(PassportType $type): self
{
$this->type = $type;
return $this;
}
public function isVerified(): ?bool
{
return $this->verified;
}
public function setVerified(?bool $verified): self
{
$this->verified = $verified;
return $this;
}
public function isMain(): ?bool
{
return $this->main;
}
public function setMain(?bool $main): self
{
$this->main = $main;
return $this;
}
}