src/Entity/Engineer.php line 27

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