src/Entity/Workers.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\WorkersRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use ApiPlatform\Metadata\ApiFilter;
  10. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Serializer\Annotation\MaxDepth;
  13. use ApiPlatform\Core\Annotation\ApiProperty;
  14. #[ApiFilter(SearchFilter::class, properties: [
  15.     'fullName' => 'ipartial'
  16.     'codeIpn' => 'exact'
  17.     'phone' => 'exact'
  18.     'code1c' => 'exact'
  19.     'email' => 'exact'
  20.     'accountWorkers.account.user.id' => 'exact'
  21.     'accountWorkers.account.id' => 'exact'
  22.     'accountWorkers.account.name' => 'ipartial'
  23.     'manager.id' => 'exact'
  24.     'manager.firstName' => 'ipartial',
  25.     'phone' => 'exact',
  26. ])]
  27. #[ORM\Entity(repositoryClassWorkersRepository::class)]
  28. #[ApiResource(
  29.     normalizationContext: ['groups' => ['worker:read']],
  30.     denormalizationContext: ['groups' => ['worker:write']],
  31.     order: ['id' => 'DESC'],
  32. )]
  33. class Workers
  34. {
  35.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read''job_woker:read'])]
  36.     #[ORM\Id]
  37.     #[ORM\GeneratedValue]
  38.     #[ORM\Column]
  39.     private ?int $id null;
  40.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read''job_woker:read'])]
  41.     #[ORM\Column(length255)] 
  42.     private ?string $fullName null;
  43.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write'])]
  44.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  45.     private ?\DateTimeInterface $dateEntered null;
  46.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read'])]
  47.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  48.     private ?string $description null;
  49.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read''job_woker:read'])]
  50.     #[ORM\Column(length100nullabletrueoptions: ["default" => ""])]
  51.     private ?string $code1c '';
  52.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read'])]
  53.     #[ORM\Column(length100nullabletrueuniquetrue)]
  54.     private ?string $codeIpn null;
  55.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read''job_woker:read'])]
  56.     #[ORM\Column(length50nullabletrue)]
  57.     private ?string $phone null;
  58.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read'])]
  59.     #[ORM\Column(length50nullabletrue)]
  60.     private ?string $email null;
  61.     #[ORM\OneToMany(mappedBy'worker'targetEntityAccountWorker::class)]
  62.     private Collection $accountWorkers;
  63.     #[ORM\OneToMany(mappedBy'worker'targetEntityJobWorker::class)]
  64.     private Collection $jobWorkers;
  65.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read'])]
  66.     #[ORM\ManyToOne(inversedBy'workers')]
  67.     private ?MediaObject $photo null;
  68.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read'])]
  69.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  70.     private ?\DateTimeInterface $dateStart null;
  71.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read'])]
  72.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  73.     private ?\DateTimeInterface $dateEnd null;
  74.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read''job_woker:read'])]
  75.     #[ORM\Column(length255nullabletrue)]
  76.     private ?string $position null;
  77.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read''job_woker:read'])]
  78.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  79.     private ?\DateTimeInterface $dateOfBirth null;
  80.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read''job_woker:read'])]
  81.     #[ORM\Column(length10nullabletrue)]
  82.     private ?string $seriaPasport null;
  83.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read''job_woker:read'])]
  84.     #[ORM\Column(length10nullabletrue)]
  85.     private ?string $numberPasport null;
  86.     
  87.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read'])]
  88.     #[ORM\OneToOne(cascade: ['persist''remove'])]
  89.     private ?MediaObject $userImage null;
  90.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write''job:read''job_woker:read'])]
  91.     #[ORM\Column(length100nullabletrue)]
  92.     private ?string $status null;
  93.     #[ORM\OneToMany(mappedBy'driver'targetEntitySpecialMachinery::class)]
  94.     private Collection $specialMachineries;
  95.     public function __construct()
  96.     {
  97.         $this->accountWorkers = new ArrayCollection();
  98.         $this->jobWorkers = new ArrayCollection();
  99.         $this->specialMachineries = new ArrayCollection();
  100.     }
  101.     public function getId(): ?int
  102.     {
  103.         return $this->id;
  104.     }
  105.     public function getFullName(): ?string
  106.     {
  107.         return $this->fullName;
  108.     }
  109.     public function setFullName(string $fullName): self
  110.     {
  111.         $this->fullName $fullName;
  112.         return $this;
  113.     }
  114.     public function getDateEntered(): ?\DateTimeInterface
  115.     {
  116.         return $this->dateEntered;
  117.     }
  118.     public function setDateEntered(?\DateTimeInterface $dateEntered): self
  119.     {
  120.         $this->dateEntered $dateEntered;
  121.         return $this;
  122.     }
  123.     public function getDescription(): ?string
  124.     {
  125.         return $this->description;
  126.     }
  127.     public function setDescription(?string $description): self
  128.     {
  129.         $this->description $description;
  130.         return $this;
  131.     }
  132.     public function getCode1c(): ?string
  133.     {
  134.         return $this->code1c;
  135.     }
  136.     public function setCode1c(?string $code1c): self
  137.     {
  138.         $this->code1c $code1c;
  139.         return $this;
  140.     }
  141.     public function getCodeIpn(): ?string
  142.     {
  143.         return $this->codeIpn;
  144.     }
  145.     public function setCodeIpn(?string $codeIpn): self
  146.     {
  147.         $this->codeIpn $codeIpn;
  148.         return $this;
  149.     }
  150.     public function getPhone(): ?string
  151.     {
  152.         return $this->phone;
  153.     }
  154.     public function setPhone(?string $phone): self
  155.     {
  156.         $this->phone $phone;
  157.         return $this;
  158.     }
  159.     public function getEmail(): ?string
  160.     {
  161.         return $this->email;
  162.     }
  163.     public function setEmail(?string $email): self
  164.     {
  165.         $this->email $email;
  166.         return $this;
  167.     }
  168.     /**
  169.      * @return Collection<int, AccountWorker>
  170.      */
  171.     public function getAccountWorkers(): Collection
  172.     {
  173.         return $this->accountWorkers;
  174.     }
  175.     public function addAccountWorker(AccountWorker $accountWorker): self
  176.     {
  177.         if (!$this->accountWorkers->contains($accountWorker)) {
  178.             $this->accountWorkers->add($accountWorker);
  179.             $accountWorker->setWorker($this);
  180.         }
  181.         return $this;
  182.     }
  183.     public function removeAccountWorker(AccountWorker $accountWorker): self
  184.     {
  185.         if ($this->accountWorkers->removeElement($accountWorker)) {
  186.             // set the owning side to null (unless already changed)
  187.             if ($accountWorker->getWorker() === $this) {
  188.                 $accountWorker->setWorker(null);
  189.             }
  190.         }
  191.         return $this;
  192.     }
  193.     /**
  194.      * @return Collection<int, JobWorker>
  195.      */
  196.     public function getJobWorkers(): Collection
  197.     {
  198.         return $this->jobWorkers;
  199.     }
  200.     public function addJobWorker(JobWorker $jobWorker): self
  201.     {
  202.         if (!$this->jobWorkers->contains($jobWorker)) {
  203.             $this->jobWorkers->add($jobWorker);
  204.             $jobWorker->setWorker($this);
  205.         }
  206.         return $this;
  207.     }
  208.     public function removeJobWorker(JobWorker $jobWorker): self
  209.     {
  210.         if ($this->jobWorkers->removeElement($jobWorker)) {
  211.             // set the owning side to null (unless already changed)
  212.             if ($jobWorker->getWorker() === $this) {
  213.                 $jobWorker->setWorker(null);
  214.             }
  215.         }
  216.         return $this;
  217.     }
  218.     public function getPhoto(): ?MediaObject
  219.     {
  220.         return $this->photo;
  221.     }
  222.     public function setPhoto(?MediaObject $photo): self
  223.     {
  224.         $this->photo $photo;
  225.         return $this;
  226.     }
  227.     public function getDateStart(): ?\DateTimeInterface
  228.     {
  229.         return $this->dateStart;
  230.     }
  231.     public function setDateStart(?\DateTimeInterface $dateStart): self
  232.     {
  233.         $this->dateStart $dateStart;
  234.         return $this;
  235.     }
  236.     public function getDateEnd(): ?\DateTimeInterface
  237.     {
  238.         return $this->dateEnd;
  239.     }
  240.     public function setDateEnd(?\DateTimeInterface $dateEnd): self
  241.     {
  242.         $this->dateEnd $dateEnd;
  243.         return $this;
  244.     }
  245.     public function getPosition(): ?string
  246.     {
  247.         return $this->position;
  248.     }
  249.     public function setPosition(string $position): self
  250.     {
  251.         $this->position $position;
  252.         return $this;
  253.     }
  254.     public function getdateOfBirth(): ?\DateTimeInterface
  255.     {
  256.         return $this->dateOfBirth;
  257.     }
  258.     public function setdateOfBirth(?\DateTimeInterface $dateOfBirth): self
  259.     {
  260.         $this->dateOfBirth $dateOfBirth;
  261.         return $this;
  262.     }
  263.     public function getSeriaPasport(): ?string
  264.     {
  265.         return $this->seriaPasport;
  266.     }
  267.     public function setSeriaPasport(?string $seriaPasport): self
  268.     {
  269.         $this->seriaPasport $seriaPasport;
  270.         return $this;
  271.     }
  272.     public function getNumberPasport(): ?string
  273.     {
  274.         return $this->numberPasport;
  275.     }
  276.     public function setNumberPasport(?string $numberPasport): self
  277.     {
  278.         $this->numberPasport $numberPasport;
  279.         return $this;
  280.     }
  281.     public function getUserImage(): ?MediaObject
  282.     {
  283.         return $this->userImage;
  284.     }
  285.     public function setUserImage(?MediaObject $userImage): self
  286.     {
  287.         $this->userImage $userImage;
  288.         return $this;
  289.     }
  290.     public function getStatus(): ?string
  291.     {
  292.         return $this->status;
  293.     }
  294.     public function setStatus(?string $status): self
  295.     {
  296.         $this->status $status;
  297.         return $this;
  298.     }
  299.     /**
  300.      * @return Collection<int, SpecialMachinery>
  301.      */
  302.     public function getSpecialMachineries(): Collection
  303.     {
  304.         return $this->specialMachineries;
  305.     }
  306.     public function addSpecialMachinery(SpecialMachinery $specialMachinery): static
  307.     {
  308.         if (!$this->specialMachineries->contains($specialMachinery)) {
  309.             $this->specialMachineries->add($specialMachinery);
  310.             $specialMachinery->setDriver($this);
  311.         }
  312.         return $this;
  313.     }
  314.     public function removeSpecialMachinery(SpecialMachinery $specialMachinery): static
  315.     {
  316.         if ($this->specialMachineries->removeElement($specialMachinery)) {
  317.             // set the owning side to null (unless already changed)
  318.             if ($specialMachinery->getDriver() === $this) {
  319.                 $specialMachinery->setDriver(null);
  320.             }
  321.         }
  322.         return $this;
  323.     }
  324. }