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'])]
  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'])]
  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.     public function __construct()
  91.     {
  92.         $this->accountWorkers = new ArrayCollection();
  93.         $this->jobWorkers = new ArrayCollection();
  94.     }
  95.     public function getId(): ?int
  96.     {
  97.         return $this->id;
  98.     }
  99.     public function getFullName(): ?string
  100.     {
  101.         return $this->fullName;
  102.     }
  103.     public function setFullName(string $fullName): self
  104.     {
  105.         $this->fullName $fullName;
  106.         return $this;
  107.     }
  108.     public function getDateEntered(): ?\DateTimeInterface
  109.     {
  110.         return $this->dateEntered;
  111.     }
  112.     public function setDateEntered(?\DateTimeInterface $dateEntered): self
  113.     {
  114.         $this->dateEntered $dateEntered;
  115.         return $this;
  116.     }
  117.     public function getDescription(): ?string
  118.     {
  119.         return $this->description;
  120.     }
  121.     public function setDescription(?string $description): self
  122.     {
  123.         $this->description $description;
  124.         return $this;
  125.     }
  126.     public function getCode1c(): ?string
  127.     {
  128.         return $this->code1c;
  129.     }
  130.     public function setCode1c(?string $code1c): self
  131.     {
  132.         $this->code1c $code1c;
  133.         return $this;
  134.     }
  135.     public function getCodeIpn(): ?string
  136.     {
  137.         return $this->codeIpn;
  138.     }
  139.     public function setCodeIpn(?string $codeIpn): self
  140.     {
  141.         $this->codeIpn $codeIpn;
  142.         return $this;
  143.     }
  144.     public function getPhone(): ?string
  145.     {
  146.         return $this->phone;
  147.     }
  148.     public function setPhone(?string $phone): self
  149.     {
  150.         $this->phone $phone;
  151.         return $this;
  152.     }
  153.     public function getEmail(): ?string
  154.     {
  155.         return $this->email;
  156.     }
  157.     public function setEmail(?string $email): self
  158.     {
  159.         $this->email $email;
  160.         return $this;
  161.     }
  162.     /**
  163.      * @return Collection<int, AccountWorker>
  164.      */
  165.     public function getAccountWorkers(): Collection
  166.     {
  167.         return $this->accountWorkers;
  168.     }
  169.     public function addAccountWorker(AccountWorker $accountWorker): self
  170.     {
  171.         if (!$this->accountWorkers->contains($accountWorker)) {
  172.             $this->accountWorkers->add($accountWorker);
  173.             $accountWorker->setWorker($this);
  174.         }
  175.         return $this;
  176.     }
  177.     public function removeAccountWorker(AccountWorker $accountWorker): self
  178.     {
  179.         if ($this->accountWorkers->removeElement($accountWorker)) {
  180.             // set the owning side to null (unless already changed)
  181.             if ($accountWorker->getWorker() === $this) {
  182.                 $accountWorker->setWorker(null);
  183.             }
  184.         }
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return Collection<int, JobWorker>
  189.      */
  190.     public function getJobWorkers(): Collection
  191.     {
  192.         return $this->jobWorkers;
  193.     }
  194.     public function addJobWorker(JobWorker $jobWorker): self
  195.     {
  196.         if (!$this->jobWorkers->contains($jobWorker)) {
  197.             $this->jobWorkers->add($jobWorker);
  198.             $jobWorker->setWorker($this);
  199.         }
  200.         return $this;
  201.     }
  202.     public function removeJobWorker(JobWorker $jobWorker): self
  203.     {
  204.         if ($this->jobWorkers->removeElement($jobWorker)) {
  205.             // set the owning side to null (unless already changed)
  206.             if ($jobWorker->getWorker() === $this) {
  207.                 $jobWorker->setWorker(null);
  208.             }
  209.         }
  210.         return $this;
  211.     }
  212.     public function getPhoto(): ?MediaObject
  213.     {
  214.         return $this->photo;
  215.     }
  216.     public function setPhoto(?MediaObject $photo): self
  217.     {
  218.         $this->photo $photo;
  219.         return $this;
  220.     }
  221.     public function getDateStart(): ?\DateTimeInterface
  222.     {
  223.         return $this->dateStart;
  224.     }
  225.     public function setDateStart(?\DateTimeInterface $dateStart): self
  226.     {
  227.         $this->dateStart $dateStart;
  228.         return $this;
  229.     }
  230.     public function getDateEnd(): ?\DateTimeInterface
  231.     {
  232.         return $this->dateEnd;
  233.     }
  234.     public function setDateEnd(?\DateTimeInterface $dateEnd): self
  235.     {
  236.         $this->dateEnd $dateEnd;
  237.         return $this;
  238.     }
  239.     public function getPosition(): ?string
  240.     {
  241.         return $this->position;
  242.     }
  243.     public function setPosition(string $position): self
  244.     {
  245.         $this->position $position;
  246.         return $this;
  247.     }
  248.     public function getdateOfBirth(): ?\DateTimeInterface
  249.     {
  250.         return $this->dateOfBirth;
  251.     }
  252.     public function setdateOfBirth(?\DateTimeInterface $dateOfBirth): self
  253.     {
  254.         $this->dateOfBirth $dateOfBirth;
  255.         return $this;
  256.     }
  257.     public function getSeriaPasport(): ?string
  258.     {
  259.         return $this->seriaPasport;
  260.     }
  261.     public function setSeriaPasport(?string $seriaPasport): self
  262.     {
  263.         $this->seriaPasport $seriaPasport;
  264.         return $this;
  265.     }
  266.     public function getNumberPasport(): ?string
  267.     {
  268.         return $this->numberPasport;
  269.     }
  270.     public function setNumberPasport(?string $numberPasport): self
  271.     {
  272.         $this->numberPasport $numberPasport;
  273.         return $this;
  274.     }
  275.     public function getUserImage(): ?MediaObject
  276.     {
  277.         return $this->userImage;
  278.     }
  279.     public function setUserImage(?MediaObject $userImage): self
  280.     {
  281.         $this->userImage $userImage;
  282.         return $this;
  283.     }
  284. }