src/Entity/Factory.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\FactoryRepository;
  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(repositoryClassFactoryRepository::class)]
  15. #[ApiResource(
  16.     normalizationContext: ['groups' => ['factory:read']],
  17.     denormalizationContext: ['groups' => ['factory:write']],
  18.     order: ['id' => 'DESC'],
  19. )]
  20. #[ApiFilter(SearchFilter::class, properties: [
  21.     'name' => 'ipartial'
  22.     'code1c' => 'exact'
  23. ])]
  24. class Factory
  25. {
  26.     #[Groups(['factory:read''factory:write''enginneer:read''job:read''job:write''worker:read''worker:write''account_worker:read''account:read''read''account:write' 'account_worker:read' ])]
  27.     #[ORM\Id]
  28.     #[ORM\GeneratedValue]
  29.     #[ORM\Column]
  30.     private ?int $id null;
  31.     #[Groups(['factory:read''factory:write''enginneer:read''job:read''job:write''worker:read''worker:write''account_worker:read''account:read''read''account:write'  'account_worker:read'])]
  32.     #[ORM\Column(length255nullabletrue)]
  33.     private ?string $name null;
  34.     #[Groups(['factory:read''factory:write''enginneer:read''job:read''job:write''worker:read''worker:write''account_worker:read''account:read''read''account:write' 'account_worker:read' ])]
  35.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  36.     private ?string $description null;
  37.     #[Groups(['factory:read''factory:write''enginneer:read''job:read''job:write''worker:read''worker:write''account_worker:read''account:read''read''account:write' 'account_worker:read' ])]
  38.     #[ORM\Column(length100nullabletrue)]
  39.     private ?string $code1c null;
  40.     #[Groups(['factory:read''factory:write''job:read''job:write''worker:read''worker:write''account_worker:read''account:read''read''account:write' ])]
  41.     #[ORM\OneToMany(mappedBy'factory'targetEntityEngineer::class)]
  42.     private Collection $engineers;
  43.     #[Groups(['factory:read''factory:write''enginneer:read''worker:read''worker:write''account_worker:read''account:read''read''account:write' ])]
  44.     #[ORM\OneToMany(mappedBy'factory'targetEntityJobs::class)]
  45.     private Collection $jobs;
  46.     public function __construct()
  47.     {
  48.         $this->engineers = new ArrayCollection();
  49.         $this->jobs = new ArrayCollection();
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getName(): ?string
  56.     {
  57.         return $this->name;
  58.     }
  59.     public function setName(?string $name): self
  60.     {
  61.         $this->name $name;
  62.         return $this;
  63.     }
  64.     public function getDescription(): ?string
  65.     {
  66.         return $this->description;
  67.     }
  68.     public function setDescription(?string $description): self
  69.     {
  70.         $this->description $description;
  71.         return $this;
  72.     }
  73.     public function getCode1c(): ?string
  74.     {
  75.         return $this->code1c;
  76.     }
  77.     public function setCode1c(?string $code1c): self
  78.     {
  79.         $this->code1c $code1c;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection<int, Engineer>
  84.      */
  85.     public function getEngineers(): Collection
  86.     {
  87.         return $this->engineers;
  88.     }
  89.     public function addEngineer(Engineer $engineer): self
  90.     {
  91.         if (!$this->engineers->contains($engineer)) {
  92.             $this->engineers->add($engineer);
  93.             $engineer->setFactory($this);
  94.         }
  95.         return $this;
  96.     }
  97.     public function removeEngineer(Engineer $engineer): self
  98.     {
  99.         if ($this->engineers->removeElement($engineer)) {
  100.             // set the owning side to null (unless already changed)
  101.             if ($engineer->getFactory() === $this) {
  102.                 $engineer->setFactory(null);
  103.             }
  104.         }
  105.         return $this;
  106.     }
  107.     /**
  108.      * @return Collection<int, Jobs>
  109.      */
  110.     public function getJobs(): Collection
  111.     {
  112.         return $this->jobs;
  113.     }
  114.     public function addJob(Jobs $job): self
  115.     {
  116.         if (!$this->jobs->contains($job)) {
  117.             $this->jobs->add($job);
  118.             $job->setFactory($this);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removeJob(Jobs $job): self
  123.     {
  124.         if ($this->jobs->removeElement($job)) {
  125.             // set the owning side to null (unless already changed)
  126.             if ($job->getFactory() === $this) {
  127.                 $job->setFactory(null);
  128.             }
  129.         }
  130.         return $this;
  131.     }
  132. }