src/Entity/DocContractModel.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Constants\LanguageConstants;
  4. use App\Repository\DocContractModelRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Entity(repositoryClass=DocContractModelRepository::class)
  10.  * @ORM\HasLifecycleCallbacks
  11.  * @UniqueEntity(fields={"space", "language"}, message="Ya existe un modelo de contrato para este espacio en el idioma seleccionado.")
  12.  */
  13. class DocContractModel
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="text", nullable=true)
  23.      */
  24.     private $contractualDocument;
  25.     /**
  26.      * @var \DateTime
  27.      *
  28.      * @ORM\Column(name="created_at", type="datetime", nullable=true)
  29.      */
  30.     private $createdAt;
  31.     /**
  32.      * @var int
  33.      *
  34.      * @ORM\Column(name="created_id", type="integer", nullable=true)
  35.      */
  36.     private $createdId;
  37.     /**
  38.      * @var \DateTime
  39.      *
  40.      * @ORM\Column(name="updated_at", type="datetime", nullable=true)
  41.      */
  42.     private $updatedAt;
  43.     /**
  44.      * @var int
  45.      *
  46.      * @ORM\Column(name="updated_id", type="integer", nullable=true)
  47.      */
  48.     private $updatedId;
  49.     /**
  50.      * @ORM\Column(type="integer")
  51.      * @Assert\NotBlank(message="El idioma es obligatorio.")
  52.      * @Assert\Choice(callback={LanguageConstants::class, "getAvailableLanguages"}, message="Idioma seleccionado no vĂ¡lido.")
  53.      */
  54.     private $language;
  55.     /**
  56.      * @ORM\Column(type="string", length=100)
  57.      */
  58.     private $title;
  59.     /**
  60.      * @ORM\ManyToOne(targetEntity=Space::class)
  61.      * @ORM\JoinColumn(nullable=true)
  62.      * @Assert\NotBlank(message="El espacio es obligatorio.")
  63.      */
  64.     private $space;
  65.     public function getId(): ?int
  66.     {
  67.         return $this->id;
  68.     }
  69.     public function getContractualDocument(): ?string
  70.     {
  71.         return $this->contractualDocument;
  72.     }
  73.     public function setContractualDocument(string $contractualDocument): self
  74.     {
  75.         $this->contractualDocument $contractualDocument;
  76.         return $this;
  77.     }
  78.     /**
  79.      * Set createdAt
  80.      *
  81.      * @param \Datetime $createdAt
  82.      *
  83.      * @return DocContractModel
  84.      */
  85.     public function setCreatedAt(\Datetime $createdAt)
  86.     {
  87.         $this->createdAt $createdAt;
  88.         return $this;
  89.     }
  90.     /**
  91.      * Get createdAt
  92.      *
  93.      * @return \Datetime
  94.      */
  95.     public function getCreatedAt()
  96.     {
  97.         return $this->createdAt;
  98.     }
  99.     /**
  100.      * Set createdId
  101.      *
  102.      * @param integer $createdId
  103.      *
  104.      * @return DocContractModel
  105.      */
  106.     public function setCreatedId($createdId)
  107.     {
  108.         $this->createdId $createdId;
  109.         return $this;
  110.     }
  111.     /**
  112.      * Get createdId
  113.      *
  114.      * @return int
  115.      */
  116.     public function getCreatedId()
  117.     {
  118.         return $this->createdId;
  119.     }
  120.     /**
  121.      * Set updatedAt
  122.      *
  123.      * @param \Datetime $updatedAt
  124.      *
  125.      * @return DocContractModel
  126.      */
  127.     public function setUpdatedAt(\Datetime $updatedAt)
  128.     {
  129.         $this->updatedAt $updatedAt;
  130.         return $this;
  131.     }
  132.     /**
  133.      * Get updatedAt
  134.      *
  135.      * @return \Datetime
  136.      */
  137.     public function getUpdatedAt()
  138.     {
  139.         return $this->updatedAt;
  140.     }
  141.     /**
  142.      * Set updatedId
  143.      *
  144.      * @param integer $updatedId
  145.      *
  146.      * @return DocContractModel
  147.      */
  148.     public function setUpdatedId($updatedId)
  149.     {
  150.         $this->updatedId $updatedId;
  151.         return $this;
  152.     }
  153.     /**
  154.      * Get updatedId
  155.      *
  156.      * @return int
  157.      */
  158.     public function getUpdatedId()
  159.     {
  160.         return $this->updatedId;
  161.     }
  162.     public function getLanguage(): ?int
  163.     {
  164.         return $this->language;
  165.     }
  166.     public function setLanguage(int $language): self
  167.     {
  168.         $this->language $language;
  169.         return $this;
  170.     }
  171.     /**
  172.      * @ORM\PrePersist
  173.      */
  174.     public function onPrePersist()
  175.     {
  176.         $this->createdAt = new \DateTime();
  177.         $this->updatedAt = new \DateTime();
  178.     }
  179.     /**
  180.      * @ORM\PreUpdate
  181.      */
  182.     public function onPreUpdate()
  183.     {
  184.         $this->updatedAt = new \DateTime();
  185.     }
  186.     public function getTitle(): ?string
  187.     {
  188.         return $this->title;
  189.     }
  190.     public function setTitle(string $title): self
  191.     {
  192.         $this->title $title;
  193.         return $this;
  194.     }
  195.     public function getSpace(): ?Space
  196.     {
  197.         return $this->space;
  198.     }
  199.     public function setSpace(Space $space): self
  200.     {
  201.         $this->space $space;
  202.         return $this;
  203.     }
  204. }