src/Entity/Article.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\HttpFoundation\File\File;
  5. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  6. use App\Repository\ArticleRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. /**
  10.  * @Vich\Uploadable
  11.  * @ORM\Entity(repositoryClass=ArticleRepository::class)
  12.  * @ORM\Table(name="app_article")
  13.  */
  14. class Article
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private int $id;
  22.     /**
  23.      * @ORM\Column(type="text", nullable=true)
  24.      */
  25.     private ?string $description null;
  26.     /**
  27.      * @ORM\Column(type="text", nullable=true)
  28.      */
  29.     private ?string $descriptionLocal null;
  30.     /**
  31.      * @ORM\Column(type="string", length=255, nullable=true)
  32.      */
  33.     private ?string $imageName null;
  34.     /**
  35.      * @Vich\UploadableField(mapping="article_images", fileNameProperty="imageName")
  36.      */
  37.     private ?File $imageFile null;
  38.     /**
  39.      * @ORM\Column(type="string", length=255, nullable=true)
  40.      */
  41.     private ?string $imageNameKg null;
  42.     /**
  43.      * @Vich\UploadableField(mapping="article_images", fileNameProperty="imageName")
  44.      */
  45.     private ?File $imageFileKg null;
  46.     /**
  47.      * @ORM\ManyToOne(targetEntity="App\Entity\Survey", inversedBy="article")
  48.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  49.      */
  50.     private ?Survey $survey;
  51.     /**
  52.      * @ORM\ManyToMany(targetEntity="App\Entity\Survey", mappedBy="articles")
  53.      */
  54.     private Collection $surveys;
  55.     /**
  56.      * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": "CURRENT_TIMESTAMP"})
  57.      */
  58.     private \DateTimeInterface $updatedAt;
  59.     /**
  60.      * @ORM\Column(type="integer", options={"default": 0}, nullable=true)
  61.      */
  62.     private ?int $scoreFrom 0;
  63.     /**
  64.      * @ORM\Column(type="integer", options={"default": 0}, nullable=true)
  65.      */
  66.     private ?int $scoreTo 0;
  67.     public function __construct()
  68.     {
  69.         $this->surveys = new ArrayCollection();
  70.     }
  71.     public function getId(): int
  72.     {
  73.         return $this->id;
  74.     }
  75.     public function __toString(): string
  76.     {
  77.         return $this->getDescription();
  78.     }
  79.     public function getDescription(): ?string
  80.     {
  81.         return $this->description;
  82.     }
  83.     public function setDescription(?string $description): self
  84.     {
  85.         $this->description $description;
  86.         return $this;
  87.     }
  88.     public function getDescriptionLocal(): ?string
  89.     {
  90.         return $this->descriptionLocal;
  91.     }
  92.     public function setDescriptionLocal(?string $descriptionLocal): self
  93.     {
  94.         $this->descriptionLocal $descriptionLocal;
  95.         return $this;
  96.     }
  97.     public function setImageFile(?File $imageFile null): void
  98.     {
  99.         $this->imageFile $imageFile;
  100.         if (null !== $imageFile) {
  101.             $this->updatedAt = new \DateTimeImmutable();
  102.         }
  103.     }
  104.     public function getImageFile(): ?File
  105.     {
  106.         return $this->imageFile;
  107.     }
  108.     public function setImageName(?string $imageName): void
  109.     {
  110.         $this->imageName $imageName;
  111.     }
  112.     public function getImageName(): ?string
  113.     {
  114.         return $this->imageName;
  115.     }
  116.     public function setImageFileKg(?File $imageFileKg null): void
  117.     {
  118.         $this->imageFileKg $imageFileKg;
  119.         if (null !== $imageFileKg) {
  120.             $this->updatedAt = new \DateTimeImmutable();
  121.         }
  122.     }
  123.     public function getImageFileKg(): ?File
  124.     {
  125.         return $this->imageFileKg;
  126.     }
  127.     public function setImageNameKg(?string $imageNameKg): void
  128.     {
  129.         $this->imageNameKg $imageNameKg;
  130.     }
  131.     public function getImageNameKg(): ?string
  132.     {
  133.         return $this->imageNameKg;
  134.     }
  135.     public function getSurvey(): ?Survey
  136.     {
  137.         return $this->survey;
  138.     }
  139.     public function setSurvey(?Survey $survey): self
  140.     {
  141.         $this->survey $survey;
  142.         return $this;
  143.     }
  144.     public function getScoreTo(): ?int
  145.     {
  146.         return $this->scoreTo;
  147.     }
  148.     public function setScoreTo(?int $scoreTo): self
  149.     {
  150.         $this->scoreTo $scoreTo;
  151.         return $this;
  152.     }
  153.     public function getScoreFrom(): ?int
  154.     {
  155.         return $this->scoreFrom;
  156.     }
  157.     public function setScoreFrom(?int $scoreFrom): self
  158.     {
  159.         $this->scoreFrom $scoreFrom;
  160.         return $this;
  161.     }
  162.     /** @return Collection<int, Survey> */
  163.     public function getSurveys(): Collection
  164.     {
  165.         return $this->surveys;
  166.     }
  167.     public function addSurvey(Survey $survey): self
  168.     {
  169.         if (!$this->surveys->contains($survey)) {
  170.             $this->surveys->add($survey);
  171.         }
  172.         return $this;
  173.     }
  174.     public function removeSurvey(Survey $survey): self
  175.     {
  176.         $this->surveys->removeElement($survey);
  177.         return $this;
  178.     }
  179. }