src/Entity/AccountWorker.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\AccountWorkerRepository;
  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. #[ORM\Entity(repositoryClassAccountWorkerRepository::class)]
  15. #[ApiResource(
  16.     normalizationContext: ['groups' => ['account_worker:read']],
  17.     denormalizationContext: ['groups' => ['account_worker:write']],
  18.     order: ['id' => 'DESC'],
  19. )]
  20. #[ApiFilter(
  21.     SearchFilter::class, 
  22.     properties: [
  23.         'account.id' => 'exact'
  24.         // 'account.user.id' => 'exact', 
  25.         'worker.id' => 'exact'
  26.     ]
  27. )]
  28. class AccountWorker
  29. {
  30.     #[Groups(['account_worker:read''account_worker:write''account:read''read''account:write''write''worker:read''worker:write'])]
  31.     #[ORM\Id]
  32.     #[ORM\GeneratedValue]
  33.     #[ORM\Column]
  34.     private ?int $id null
  35.     #[Groups(['account_worker:read''account_worker:write''worker:read''worker:write'])]
  36.     #[ORM\ManyToOne(inversedBy'accountWorkers')]
  37.     #[ORM\JoinColumn(nullablefalse)]
  38.     private ?Accounts $account null;
  39.     #[Groups(['account_worker:read''account_worker:write''account:read''read''account:write''write'])]
  40.     #[ORM\ManyToOne(inversedBy'accountWorkers')]
  41.     private ?Workers $worker null;
  42.     #[Groups(['account_worker:read''account_worker:write''account:read''read''account:write''write''worker:read''worker:write'])]
  43.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  44.     private ?\DateTimeInterface $dateEntered null;
  45.     #[Groups(['account_worker:read''account_worker:write''account:read''read''account:write''write''worker:read''worker:write'])]
  46.     #[ORM\OneToMany(mappedBy'accountWorker'targetEntityMediaObject::class)]
  47.     private Collection $media;
  48.     #[Groups(['account_worker:read''account_worker:write''account:read''read''account:write''write''worker:read''worker:write'])]
  49.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  50.     private ?string $description null;
  51.     #[Groups(['account_worker:read''account_worker:write''account:read''read''account:write''write''worker:read''worker:write'])]
  52.     #[ORM\Column(length100nullabletrue)]
  53.     private ?string $code1c null;
  54.     public function __construct()
  55.     {
  56.         $this->media = new ArrayCollection();
  57.     }
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getAccount(): ?Accounts
  63.     {
  64.         return $this->account;
  65.     }
  66.     public function setAccount(?Accounts $account): self
  67.     {
  68.         $this->account $account;
  69.         return $this;
  70.     }
  71.     public function getWorker(): ?Workers
  72.     {
  73.         return $this->worker;
  74.     }
  75.     public function setWorker(?Workers $worker): self
  76.     {
  77.         $this->worker $worker;
  78.         return $this;
  79.     }
  80.     public function getDateEntered(): ?\DateTimeInterface
  81.     {
  82.         return $this->dateEntered;
  83.     }
  84.     public function setDateEntered(?\DateTimeInterface $dateEntered): self
  85.     {
  86.         $this->dateEntered $dateEntered;
  87.         return $this;
  88.     }
  89.     /**
  90.      * @return Collection<int, MediaObject>
  91.      */
  92.     public function getMedia(): Collection
  93.     {
  94.         return $this->media;
  95.     }
  96.     public function addMedium(MediaObject $medium): self
  97.     {
  98.         if (!$this->media->contains($medium)) {
  99.             $this->media->add($medium);
  100.             $medium->setAccountWorker($this);
  101.         }
  102.         return $this;
  103.     }
  104.     public function removeMedium(MediaObject $medium): self
  105.     {
  106.         if ($this->media->removeElement($medium)) {
  107.             // set the owning side to null (unless already changed)
  108.             if ($medium->getAccountWorker() === $this) {
  109.                 $medium->setAccountWorker(null);
  110.             }
  111.         }
  112.         return $this;
  113.     }
  114.     public function getDescription(): ?string
  115.     {
  116.         return $this->description;
  117.     }
  118.     public function setDescription(?string $description): self
  119.     {
  120.         $this->description $description;
  121.         return $this;
  122.     }
  123.     public function getCode1c(): ?string
  124.     {
  125.         return $this->code1c;
  126.     }
  127.     public function setCode1c(?string $code1c): self
  128.     {
  129.         $this->code1c $code1c;
  130.         return $this;
  131.     }
  132. }