src/Entity/Fleet/Driver.php line 23

  1. <?php
  2. namespace App\Entity\Fleet;
  3. use App\Doctrine\Type\Fleet\OperatingStatus;
  4. use App\Entity\Common as Common;
  5. use App\Entity\Common\Company;
  6. use App\Validator\IsValidEnum\IsValidEnum;
  7. use DateTimeInterface;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. use Symfony\Component\Uid\Ulid;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. #[ORM\Table(name'fleet_driver')]
  14. #[ORM\Index(columns: ['employer_id'], name'fleet_driver_employer_id_idx')]
  15. #[ORM\Index(columns: ['created_by'], name'fleet_driver_created_by_idx')]
  16. #[ORM\Index(columns: ['updated_by'], name'fleet_driver_updated_by_idx')]
  17. #[ORM\UniqueConstraint(name'fleet_driver_identifier_key'columns: ['identifier'])]
  18. #[ORM\Entity]
  19. #[UniqueEntity(fields: ['identifier'])]
  20. class Driver
  21. {
  22.     use Common\Blameable;
  23.     use Common\Trackable;
  24.     #[ORM\Id]
  25.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  26.     #[ORM\SequenceGenerator(sequenceName'fleet_driver_id_seq')]
  27.     #[ORM\Column(typeTypes::INTEGER)]
  28.     private ?int $id null;
  29.     #[Assert\Ulid]
  30.     #[Assert\NotNull]
  31.     #[ORM\Column(type'ulid'uniquetrue)]
  32.     private ?Ulid $identifier null;
  33.     #[ORM\ManyToOne(targetEntityCompany::class)]
  34.     #[ORM\JoinColumn(name'employer_id')]
  35.     private ?Company $employer null;
  36.     #[Assert\NotBlank]
  37.     #[Assert\Type(typeTypes::STRING)]
  38.     #[ORM\Column(typeTypes::STRING)]
  39.     private ?string $lastName null;
  40.     #[Assert\Type(typeTypes::STRING)]
  41.     #[ORM\Column(typeTypes::STRINGnullabletrue)]
  42.     private ?string $firstName null;
  43.     #[Assert\Type(typeDateTimeInterface::class)]
  44.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  45.     private ?DateTimeInterface $bornOn null;
  46.     #[Assert\NotBlank]
  47.     #[Assert\Type(typeTypes::STRING)]
  48.     #[ORM\Column(typeTypes::STRING)]
  49.     private ?string $countryOfOperation null;
  50.     #[Assert\NotNull]
  51.     #[IsValidEnum(enumOperatingStatus::class)]
  52.     #[ORM\Column(typeTypes::STRINGnullablefalseenumTypeOperatingStatus::class, options: ['default' => 'OPERATIONAL'])]
  53.     private ?OperatingStatus $status OperatingStatus::OPERATIONAL;
  54.     public function __construct()
  55.     {
  56.         $this->identifier = new Ulid();
  57.     }
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getIdentifier(): ?Ulid
  63.     {
  64.         return $this->identifier;
  65.     }
  66.     public function setIdentifier($identifier): self
  67.     {
  68.         $this->identifier $identifier;
  69.         return $this;
  70.     }
  71.     public function getEmployer(): ?Company
  72.     {
  73.         return $this->employer;
  74.     }
  75.     public function setEmployer(Company $employer): self
  76.     {
  77.         $this->employer $employer;
  78.         return $this;
  79.     }
  80.     public function getLastName(): ?string
  81.     {
  82.         return $this->lastName;
  83.     }
  84.     public function setLastName(?string $lastName): self
  85.     {
  86.         $this->lastName $lastName;
  87.         return $this;
  88.     }
  89.     public function getFirstName(): ?string
  90.     {
  91.         return $this->firstName;
  92.     }
  93.     public function setFirstName(?string $firstName): self
  94.     {
  95.         $this->firstName $firstName;
  96.         return $this;
  97.     }
  98.     public function getBornOn(): ?DateTimeInterface
  99.     {
  100.         return $this->bornOn;
  101.     }
  102.     public function setBornOn(?DateTimeInterface $bornOn): self
  103.     {
  104.         $this->bornOn $bornOn;
  105.         return $this;
  106.     }
  107.     public function getCountryOfOperation(): ?string
  108.     {
  109.         return $this->countryOfOperation;
  110.     }
  111.     public function setCountryOfOperation(?string $countryOfOperation): self
  112.     {
  113.         $this->countryOfOperation $countryOfOperation;
  114.         return $this;
  115.     }
  116.     public function getStatus(): ?OperatingStatus
  117.     {
  118.         return $this->status;
  119.     }
  120.     public function setStatus(?OperatingStatus $status): self
  121.     {
  122.         $this->status $status;
  123.         return $this;
  124.     }
  125. }