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({"worker.manage.base", "worker.certificate.manage"})
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\ManyToOne(targetEntity=Worker::class, inversedBy="workerCertificates")
  24.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  25.      */
  26.     private $worker;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity=Certificates::class, inversedBy="workerCertificates")
  29.      * @ORM\JoinColumn(nullable=false)
  30.      * @Groups({"worker.manage.base", "worker.certificate.manage"})
  31.      */
  32.     private $certificate;
  33.     /**
  34.      * @ORM\Column(type="datetime_immutable", nullable=true)
  35.      */
  36.     private $created_at;
  37.     /**
  38.      * @ORM\OneToMany(targetEntity=WorkerCertificateHistories::class, mappedBy="worker_certificate", cascade={"persist", "remove"}, orphanRemoval=true, fetch="EXTRA_LAZY")
  39.      * @ORM\OrderBy({"valid_from_at"="DESC"})
  40.      * @Groups({"worker.manage.base"})
  41.      */
  42.     private $worker_certificate_histories;
  43.     // private $workerCertificateLastHistory;
  44.     public function __construct()
  45.     {
  46.         $this->worker_certificate_histories = new ArrayCollection();
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getWorker(): ?Worker
  53.     {
  54.         return $this->worker;
  55.     }
  56.     public function setWorker(?Worker $worker): self
  57.     {
  58.         $this->worker $worker;
  59.         return $this;
  60.     }
  61.     public function getCertificate(): ?Certificates
  62.     {
  63.         return $this->certificate;
  64.     }
  65.     public function setCertificate(?Certificates $certificate): self
  66.     {
  67.         $this->certificate $certificate;
  68.         return $this;
  69.     }
  70.     public function getCreatedAt(): ?\DateTimeImmutable
  71.     {
  72.         return $this->created_at;
  73.     }
  74.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  75.     {
  76.         $this->created_at $created_at;
  77.         return $this;
  78.     }
  79.     /**
  80.      * @return Collection<int, WorkerCertificateHistories>
  81.      */
  82.     public function getWorkerCertificateHistories(): ?Collection
  83.     {
  84.         return $this->worker_certificate_histories;
  85.     }
  86.     public function addWorkerCertificateHistory(WorkerCertificateHistories $workerCertificateHistory): self
  87.     {
  88.         if (!$this->worker_certificate_histories->contains($workerCertificateHistory)) {
  89.             $this->worker_certificate_histories[] = $workerCertificateHistory;
  90.             $workerCertificateHistory->setWorkerCertificate($this);
  91.         }
  92.         return $this;
  93.     }
  94.     public function removeWorkerCertificateHistory(WorkerCertificateHistories $workerCertificateHistory): self
  95.     {
  96.         if ($this->worker_certificate_histories->removeElement($workerCertificateHistory)) {
  97.             // set the owning side to null (unless already changed)
  98.             if ($workerCertificateHistory->getWorkerCertificate() === $this) {
  99.                 $workerCertificateHistory->setWorkerCertificate(null);
  100.             }
  101.         }
  102.         return $this;
  103.     }
  104. }