src/Entity/AdministrationSector.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AdministrationSectorRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. /**
  10.  * @ORM\Entity(repositoryClass=AdministrationSectorRepository::class)
  11.  * @ORM\HasLifecycleCallbacks()
  12.  * @Vich\Uploadable
  13.  */
  14. class AdministrationSector
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=50)
  24.      */
  25.     private $name;
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=true)
  28.      */
  29.     private $description;
  30.     /**
  31.      * @ORM\Column(type="datetime")
  32.      */
  33.     private $createdAt;
  34.     /**
  35.      * @ORM\Column(type="datetime", nullable=true)
  36.      */
  37.     private $updatedAt;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity=AdministrationMove::class, mappedBy="administrationSector")
  40.      */
  41.     private $moveId;
  42.     /**
  43.      * @ORM\Column(type="boolean")
  44.      */
  45.     private $isCredit;
  46.     /**
  47.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  48.      *
  49.      * @Vich\UploadableField(mapping="sector_image", fileNameProperty="image")
  50.      *
  51.      * @var File|null
  52.      */
  53.     private $imageFile;
  54.     /**
  55.      * @ORM\Column(type="string", length=255, nullable=true)
  56.      */
  57.     private $image;
  58.     public function __construct()
  59.     {
  60.         $this->moveId = new ArrayCollection();
  61.     }
  62.     public function getId(): ?int
  63.     {
  64.         return $this->id;
  65.     }
  66.     public function getName(): ?string
  67.     {
  68.         return $this->name;
  69.     }
  70.     public function setName(string $name): self
  71.     {
  72.         $this->name $name;
  73.         return $this;
  74.     }
  75.     public function getDescription(): ?string
  76.     {
  77.         return $this->description;
  78.     }
  79.     public function setDescription(?string $description): self
  80.     {
  81.         $this->description $description;
  82.         return $this;
  83.     }
  84.     public function getCreatedAt(): ?\DateTimeInterface
  85.     {
  86.         return $this->createdAt;
  87.     }
  88.     /**
  89.      * @ORM\PrePersist
  90.      */
  91.     public function setCreatedAt(): self
  92.     {
  93.         $this->createdAt = new \DateTime();
  94.         return $this;
  95.     }
  96.     public function getUpdatedAt(): ?\DateTimeInterface
  97.     {
  98.         return $this->updatedAt;
  99.     }
  100.     /**
  101.      * @ORM\PreUpdate
  102.      */
  103.     public function setUpdatedAt(): self
  104.     {
  105.         $this->updatedAt = new \DateTime();
  106.         return $this;
  107.     }
  108.     /**
  109.      * @return Collection|AdministrationMove[]
  110.      */
  111.     public function getMoveId(): Collection
  112.     {
  113.         return $this->moveId;
  114.     }
  115.     public function addMoveId(AdministrationMove $moveId): self
  116.     {
  117.         if (!$this->moveId->contains($moveId)) {
  118.             $this->moveId[] = $moveId;
  119.             $moveId->setAdministrationSector($this);
  120.         }
  121.         return $this;
  122.     }
  123.     public function removeMoveId(AdministrationMove $moveId): self
  124.     {
  125.         if ($this->moveId->removeElement($moveId)) {
  126.             // set the owning side to null (unless already changed)
  127.             if ($moveId->getAdministrationSector() === $this) {
  128.                 $moveId->setAdministrationSector(null);
  129.             }
  130.         }
  131.         return $this;
  132.     }
  133.     public function getIsCreditString(): ?string
  134.     {
  135.         if ($this->isCredit) {
  136.             return 1;
  137.         } else {
  138.             return 0;
  139.         }
  140.     }
  141.     public function getIsCredit(): ?bool
  142.     {
  143.         return $this->isCredit;
  144.     }
  145.     public function setIsCredit(bool $isCredit): self
  146.     {
  147.         $this->isCredit $isCredit;
  148.         return $this;
  149.     }
  150.     public function __toString()
  151.     {
  152.         return $this->name;
  153.     }
  154.     /**
  155.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  156.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  157.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  158.      * must be able to accept an instance of 'File' as the bundle will inject one here
  159.      * during Doctrine hydration.
  160.      *
  161.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  162.      */
  163.     public function setImageFile(?File $imageFile null): void
  164.     {
  165.         $this->imageFile $imageFile;
  166.         if (null !== $imageFile) {
  167.             // It is required that at least one field changes if you are using doctrine
  168.             // otherwise the event listeners won't be called and the file is lost
  169.             $this->updatedAt = new \DateTimeImmutable();
  170.         }
  171.     }
  172.     public function getImageFile(): ?File
  173.     {
  174.         return $this->imageFile;
  175.     }
  176.     public function getImage(): ?string
  177.     {
  178.         return $this->image;
  179.     }
  180.     public function setImage(?string $image): self
  181.     {
  182.         $this->image $image;
  183.         return $this;
  184.     }
  185. }