src/Entity/BuildingDictionary.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Building;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * BuildingDictionary
  10.  *
  11.  * @ORM\Table(name="building_dictionary")
  12.  * @ORM\Entity(repositoryClass="App\Repository\BuildingDictionaryRepository")
  13.  */
  14. class BuildingDictionary
  15. {
  16.     /**
  17.      * @ORM\Column(name="id", type="integer")
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue(strategy="AUTO")
  20.      */
  21.     private int $id;
  22.     /**
  23.      * @ORM\Column(name="name", type="string", length=255)
  24.      */
  25.     private string $name;
  26.     /**
  27.      * @ORM\Column(name="createdAt", type="datetime")
  28.      */
  29.     private DateTime|null $createdAt;
  30.     /**
  31.      * @ORM\Column(name="updatedAt", type="datetime", nullable=true)
  32.      */
  33.     private DateTime|null $updatedAt;
  34.     /**
  35.      * @ORM\Column(type="string", nullable=true)
  36.      * @Assert\File(mimeTypes={ "application/pdf" })
  37.      */
  38.     private File|string|null $contract;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity="Building", inversedBy="buildingDictionaries", cascade={"persist"})
  41.      * @ORM\JoinColumn(name="building_id", referencedColumnName="id", onDelete="CASCADE")
  42.      */
  43.     private Building $building;
  44.     /**
  45.      * @ORM\Column(name="createdBy", type="string", nullable=true)
  46.      */
  47.     private string|null $createdBy;
  48.     /**
  49.      * @ORM\Column(name="selectedDate", type="datetime", nullable=true)
  50.      */
  51.     private DateTime|null $selectedDate;
  52.     /**
  53.      * @ORM\Column(name="enteredUser", type="string", length=100, nullable=true)
  54.      */
  55.     private string|null $enteredUser;
  56.     /**
  57.      * @var string
  58.      *
  59.      * @ORM\Column(name="type", type="string", length=255)
  60.      */
  61.     private string $type;
  62.     /**
  63.      * @var string
  64.      *
  65.      * @Assert\Length(
  66.      *     max = 1024,
  67.      *     maxMessage = "Opis treba da ima maksimalno {{ limit }} karaktera."
  68.      * )
  69.      *
  70.      * @ORM\Column(name="notes", type="string", length=1024)
  71.      */
  72.     private string $notes;
  73.     /**
  74.      * @return string
  75.      */
  76.     public function getCreatedBy(): string
  77.     {
  78.         return $this->createdBy;
  79.     }
  80.     /**
  81.      * @return Building
  82.      */
  83.     public function getBuilding(): Building
  84.     {
  85.         return $this->building;
  86.     }
  87.     /**
  88.      * @param Building $building
  89.      */
  90.     public function setBuilding(Building $building): void
  91.     {
  92.         $this->building $building;
  93.         if (empty($this->createdBy)) {
  94.             $user $building->getUser();
  95.             $this->createdBy $user->getCreatedByValue();
  96.         }
  97.     }
  98.     /**
  99.      * @return string
  100.      */
  101.     public function getType(): string
  102.     {
  103.         return $this->type;
  104.     }
  105.     /**
  106.      * @param string $type
  107.      */
  108.     public function setType(string $type): void
  109.     {
  110.         $this->type $type;
  111.     }
  112.     /**
  113.      * @return string
  114.      */
  115.     public function getNotes(): string
  116.     {
  117.         return $this->notes;
  118.     }
  119.     /**
  120.      * @param string $notes
  121.      */
  122.     public function setNotes(string $notes): void
  123.     {
  124.         $this->notes $notes;
  125.     }
  126.     public function __construct()
  127.     {
  128.         $this->setCreatedAt(new DateTime());
  129.         $this->setUpdatedAt(new DateTime());
  130.         $this->enteredUser null;
  131.         $this->contract null;
  132.     }
  133.     /**
  134.      * @ORM\PreUpdate
  135.      */
  136.     public function setUpdateAtValue(): void
  137.     {
  138.         $this->updatedAt = new \DateTime();
  139.     }
  140.     /**
  141.      * Get id
  142.      *
  143.      * @return int
  144.      */
  145.     public function getId(): int
  146.     {
  147.         return $this->id;
  148.     }
  149.     /**
  150.      * @param string $name
  151.      *
  152.      * @return $this
  153.      */
  154.     public function setName(string $name): self
  155.     {
  156.         $this->name $name;
  157.         return $this;
  158.     }
  159.     /**
  160.      * Get name
  161.      *
  162.      * @return string
  163.      */
  164.     public function getName(): string
  165.     {
  166.         return $this->name;
  167.     }
  168.     /**
  169.      * Set createdAt
  170.      *
  171.      * @param DateTime|null $createdAt
  172.      *
  173.      * @return BuildingDictionary
  174.      */
  175.     public function setCreatedAt(?DateTime $createdAt): self
  176.     {
  177.         $this->createdAt $createdAt;
  178.         return $this;
  179.     }
  180.     /**
  181.      * Get createdAt
  182.      *
  183.      * @return DateTime|null
  184.      */
  185.     public function getCreatedAt(): ?DateTime
  186.     {
  187.         return $this->createdAt;
  188.     }
  189.     /**
  190.      * @param DateTime|null $updatedAt
  191.      * @return BuildingDictionary
  192.      */
  193.     public function setUpdatedAt(?DateTime $updatedAt): self
  194.     {
  195.         $this->updatedAt $updatedAt;
  196.         return $this;
  197.     }
  198.     /**
  199.      * @return DateTime|null
  200.      */
  201.     public function getUpdatedAt(): ?DateTime
  202.     {
  203.         return $this->updatedAt;
  204.     }
  205.     /**
  206.      * @param File|string|null $contract
  207.      * @return BuildingDictionary
  208.      */
  209.     public function setContract(File|string|null $contract): BuildingDictionary
  210.     {
  211.         $this->contract $contract;
  212.         return $this;
  213.     }
  214.     /**
  215.      * @return File|string|null
  216.      */
  217.     public function getContract(): File|string|null
  218.     {
  219.         return $this->contract;
  220.     }
  221.     /**
  222.      * @return DateTime|null
  223.      */
  224.     public function getSelectedDate(): ?DateTime
  225.     {
  226.         return $this->selectedDate;
  227.     }
  228.     /**
  229.      * @param DateTime|null $selectedDate
  230.      */
  231.     public function setSelectedDate(?DateTime $selectedDate): void
  232.     {
  233.         $this->selectedDate $selectedDate;
  234.     }
  235.     /**
  236.      * @return string|null
  237.      */
  238.     public function getEnteredUser(): ?string
  239.     {
  240.         return $this->enteredUser;
  241.     }
  242.     /**
  243.      * @param string|null $enteredUser
  244.      */
  245.     public function setEnteredUser(?string $enteredUser): void
  246.     {
  247.         $this->enteredUser $enteredUser;
  248.     }
  249.     public function __toString()
  250.     {
  251.         return (string) $this->getName();
  252.     }
  253. }