src/Entity/Jobs.php line 31

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