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'])]
  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'])]
  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'])]
  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'])]
  50.     #[ORM\Column(length100nullabletrue)]
  51.     private ?string $code1c null;
  52.     #[Groups(['worker:read''worker:write''account_worker:read''account_worker:write''account:read''read''account:write''write'])]
  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'])]
  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'])]
  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.     public function __construct()
  66.     {
  67.         $this->accountWorkers = new ArrayCollection();
  68.         $this->jobWorkers = new ArrayCollection();
  69.     }
  70.     public function getId(): ?int
  71.     {
  72.         return $this->id;
  73.     }
  74.     public function getFullName(): ?string
  75.     {
  76.         return $this->fullName;
  77.     }
  78.     public function setFullName(string $fullName): self
  79.     {
  80.         $this->fullName $fullName;
  81.         return $this;
  82.     }
  83.     public function getDateEntered(): ?\DateTimeInterface
  84.     {
  85.         return $this->dateEntered;
  86.     }
  87.     public function setDateEntered(?\DateTimeInterface $dateEntered): self
  88.     {
  89.         $this->dateEntered $dateEntered;
  90.         return $this;
  91.     }
  92.     public function getDescription(): ?string
  93.     {
  94.         return $this->description;
  95.     }
  96.     public function setDescription(?string $description): self
  97.     {
  98.         $this->description $description;
  99.         return $this;
  100.     }
  101.     public function getCode1c(): ?string
  102.     {
  103.         return $this->code1c;
  104.     }
  105.     public function setCode1c(?string $code1c): self
  106.     {
  107.         $this->code1c $code1c;
  108.         return $this;
  109.     }
  110.     public function getCodeIpn(): ?string
  111.     {
  112.         return $this->codeIpn;
  113.     }
  114.     public function setCodeIpn(?string $codeIpn): self
  115.     {
  116.         $this->codeIpn $codeIpn;
  117.         return $this;
  118.     }
  119.     public function getPhone(): ?string
  120.     {
  121.         return $this->phone;
  122.     }
  123.     public function setPhone(?string $phone): self
  124.     {
  125.         $this->phone $phone;
  126.         return $this;
  127.     }
  128.     public function getEmail(): ?string
  129.     {
  130.         return $this->email;
  131.     }
  132.     public function setEmail(?string $email): self
  133.     {
  134.         $this->email $email;
  135.         return $this;
  136.     }
  137.     /**
  138.      * @return Collection<int, AccountWorker>
  139.      */
  140.     public function getAccountWorkers(): Collection
  141.     {
  142.         return $this->accountWorkers;
  143.     }
  144.     public function addAccountWorker(AccountWorker $accountWorker): self
  145.     {
  146.         if (!$this->accountWorkers->contains($accountWorker)) {
  147.             $this->accountWorkers->add($accountWorker);
  148.             $accountWorker->setWorker($this);
  149.         }
  150.         return $this;
  151.     }
  152.     public function removeAccountWorker(AccountWorker $accountWorker): self
  153.     {
  154.         if ($this->accountWorkers->removeElement($accountWorker)) {
  155.             // set the owning side to null (unless already changed)
  156.             if ($accountWorker->getWorker() === $this) {
  157.                 $accountWorker->setWorker(null);
  158.             }
  159.         }
  160.         return $this;
  161.     }
  162.     /**
  163.      * @return Collection<int, JobWorker>
  164.      */
  165.     public function getJobWorkers(): Collection
  166.     {
  167.         return $this->jobWorkers;
  168.     }
  169.     public function addJobWorker(JobWorker $jobWorker): self
  170.     {
  171.         if (!$this->jobWorkers->contains($jobWorker)) {
  172.             $this->jobWorkers->add($jobWorker);
  173.             $jobWorker->setWorker($this);
  174.         }
  175.         return $this;
  176.     }
  177.     public function removeJobWorker(JobWorker $jobWorker): self
  178.     {
  179.         if ($this->jobWorkers->removeElement($jobWorker)) {
  180.             // set the owning side to null (unless already changed)
  181.             if ($jobWorker->getWorker() === $this) {
  182.                 $jobWorker->setWorker(null);
  183.             }
  184.         }
  185.         return $this;
  186.     }
  187. }