src/Entity/WorkerCertificates.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\WorkerCertificatesRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Event\LifecycleEventArgs;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. /**
  10.  * @ORM\Entity(repositoryClass=WorkerCertificatesRepository::class)
  11.  * @ORM\HasLifecycleCallbacks
  12.  */
  13. class WorkerCertificates
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      * @Groups({
  20.      *     "worker.manage.base",
  21.      *     "worker.certificate.manage",
  22.      *
  23.      *     "worker_certificate@core"
  24.      * })
  25.      */
  26.     private $id;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity=Worker::class, inversedBy="workerCertificates")
  29.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  30.      * @Groups({
  31.      *      "worker.manage.base",
  32.      *      "worker.certificate.manage",
  33.      *
  34.      *      "worker_certificate@worker"
  35.      *  })
  36.      */
  37.     private $worker;
  38.     /**
  39.      * @ORM\ManyToOne(targetEntity=Certificates::class, inversedBy="worker_certificates")
  40.      * @ORM\JoinColumn(nullable=false)
  41.      * @Groups({
  42.      *       "worker.manage.base",
  43.      *       "worker.certificate.manage",
  44.      *
  45.      *       "worker_certificate@certificate"
  46.      *   })
  47.      */
  48.     private $certificate;
  49.     /**
  50.      * @ORM\Column(type="datetime_immutable", nullable=true)
  51.      * @Groups({
  52.      *       "worker.manage.base",
  53.      *       "worker.certificate.manage",
  54.      *
  55.      *       "worker_certificate@core"
  56.      *   })
  57.      */
  58.     private $created_at;
  59.     /**
  60.      * @ORM\OneToMany(targetEntity=WorkerCertificateHistories::class, mappedBy="worker_certificate", cascade={"persist", "remove"}, orphanRemoval=true, fetch="EXTRA_LAZY")
  61.      * @ORM\OrderBy({"valid_from_at"="DESC"})
  62.      * @Groups({"worker.manage.base"})
  63.      * @Groups({
  64.      *       "worker_certificate@histories"
  65.      *   })
  66.      */
  67.     private $worker_certificate_histories;
  68.     // private $workerCertificateLastHistory;
  69.     public function __construct()
  70.     {
  71.         $this->worker_certificate_histories = new ArrayCollection();
  72.     }
  73.     public function getId(): ?int
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function getWorker(): ?Worker
  78.     {
  79.         return $this->worker;
  80.     }
  81.     public function setWorker(?Worker $worker): self
  82.     {
  83.         $this->worker $worker;
  84.         return $this;
  85.     }
  86.     public function getCertificate(): ?Certificates
  87.     {
  88.         return $this->certificate;
  89.     }
  90.     public function setCertificate(?Certificates $certificate): self
  91.     {
  92.         $this->certificate $certificate;
  93.         return $this;
  94.     }
  95.     public function getCreatedAt(): ?\DateTimeImmutable
  96.     {
  97.         return $this->created_at;
  98.     }
  99.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  100.     {
  101.         $this->created_at $created_at;
  102.         return $this;
  103.     }
  104.     /**
  105.      * @return Collection<int, WorkerCertificateHistories>
  106.      */
  107.     public function getWorkerCertificateHistories(): ?Collection
  108.     {
  109.         return $this->worker_certificate_histories;
  110.     }
  111.     public function addWorkerCertificateHistory(WorkerCertificateHistories $workerCertificateHistory): self
  112.     {
  113.         if (!$this->worker_certificate_histories->contains($workerCertificateHistory)) {
  114.             $this->worker_certificate_histories[] = $workerCertificateHistory;
  115.             $workerCertificateHistory->setWorkerCertificate($this);
  116.         }
  117.         return $this;
  118.     }
  119.     public function removeWorkerCertificateHistory(WorkerCertificateHistories $workerCertificateHistory): self
  120.     {
  121.         if ($this->worker_certificate_histories->removeElement($workerCertificateHistory)) {
  122.             // set the owning side to null (unless already changed)
  123.             if ($workerCertificateHistory->getWorkerCertificate() === $this) {
  124.                 $workerCertificateHistory->setWorkerCertificate(null);
  125.             }
  126.         }
  127.         return $this;
  128.     }
  129. }